> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blobhub.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat Component (genai.chat)

> One model call over a conversation: what it sends, what it answers, and where the answer goes.

One model call over a conversation. The component, labelled **Generative AI Chat** in the editor, sends a system
message, the selected history and a current message to the model of a
[`genai.model.language`](https://docs.blobhub.io/blob-types/workflow/workflows/component-genai-model-language), and writes the model's answer
as one message. Wired to a [`data.thread`](https://docs.blobhub.io/blob-types/workflow/workflows/component-data-thread) on both `history` and
`output`, it reads a conversation and posts its answer into it
([Messages and Threads](https://docs.blobhub.io/blob-types/workflow/workflows/messages-and-threads.md)).

```mermaid theme={null}
flowchart LR
    system["system"] --> chat["genai.chat"]
    history["history<br/>a data.thread or a data.messages"] --> chat
    current["current<br/>this call only"] --> chat
    model["genai.model.language"] -->|model| chat
    chat -->|output| answer["One message<br/>posted to a thread, or written as a value"]
```

## Ports

A `genai.chat` has one flow input, which starts it, and the ports below, grouped by what they do.

### Flow

The flow outputs.

| Route | Notes |
| :- | :- |
| `success` | The answer is written, or there was nothing to answer ([What it answers](#what-it-answers)). |
| `tool_call` | The answer ended with `finish` `tool_call`, and the flow runs its calls ([Tool Calling](https://docs.blobhub.io/blob-types/workflow/workflows/tool-calling.md)). A flow whose `tools` holds any must connect it. |
| `failure` | The call failed; the reason is in the execution log ([Refusals and failures](#refusals-and-failures)). |

### Model

A provider input.

| Route | Value |
| :- | :- |
| `model` | a `genai.model.language` |

* `model`: required. The model that answers, with its credentials and settings. A run may name another
  ([Choosing a Model per Run](https://docs.blobhub.io/blob-types/workflow/workflows/choosing-a-model.md)).

### Content

Data inputs.

| Route | Value |
| :- | :- |
| `system` | `message` |
| `history` | `messages` |
| `current` | `message` |

* `system`: the instructions, sent first with its role set to `system`. Every block reaches the model: its text becomes
  the vendor's instructions, and its files go at the head of the first `user` turn. The editor fills in an empty text
  message.
* `history`: the conversation so far, read from the one data component wired here: a `data.thread` for a conversation,
  or a `data.messages` for a fixed list, such as a few-shot prompt or a frozen transcript. The history selection
  decides what of it is sent.
* `current`: this call only: sent after the history, never posted, and not sent when empty. The editor fills in an
  empty text message with the role `user`.

### History selection

Data inputs.

| Route | Value |
| :- | :- |
| `history_roles` | `list` of `text` |
| `history_skip_roles` | `list` of `text` |
| `history_anchor` | `text` |
| `history_from` | `integer` |
| `history_to` | `integer` |
| `history_keep` | `list` of `text` |
| `history_fit` | `choice`: `trim`, `fail` |

* `history_roles`: send only messages of these roles. Empty, the default, sends every role.
* `history_skip_roles`: never send messages of these roles. Defaults to `["note"]`.
* `history_anchor`: a role. The newest message of this role starts what is sent, standing in for every message its
  writer read, up to its `read.through`, and for every other message of its role. None by default.
* `history_from`: the start of a range over the messages after the anchor's `read.through` (after the anchor itself
  when it has no `read`), counted as a Python slice counts, negative from the end. The anchor is not counted. None by
  default.
* `history_to`: the end of that range, not included: `-6` leaves out the newest six. None by default.
* `history_keep`: send messages of these roles even where the anchor or the range leaves them out. Empty by default.
* `history_fit`: when the request would not fit the model's window, `trim`, the default, leaves out the oldest turns;
  `fail` fails the call ([The window guard](#the-window-guard)).

They apply in this order: roles, the anchor, the range, kept roles, then the window guard. An anchor is a hard edge: a
message its writer read is not sent again, even where the range would reach it, except in a turn the edge fell
inside, and only `history_keep` brings one
back. An anchor resumes where its writer stopped reading, not where it was posted: the messages its writer did not
read sit before it in the thread but after its `read.through`, so they are sent after it. The rules and a rolling
summary built from them are on
[Selecting a History](https://docs.blobhub.io/blob-types/workflow/workflows/selecting-a-history.md).

### Tools

Data inputs.

| Route | Value |
| :- | :- |
| `tools` | `list` of `object` |
| `tool_choice` | `choice`: `auto`, `none`, `required` |

* `tools`: each object holds `name` (`text`, required), `description` (`text`), `parameters` (`object`, required) and
  `strict` (`boolean`). The tools the model may call; `parameters` is a JSON schema. Empty by default. A catalog model
  must do `tools` when the list holds any.
* `tool_choice`: labelled Auto, None and Required. Defaults to `auto`. Whether the model may call a tool, must not, or
  must; `required` becomes `auto`, with a warning, on a model that refuses a forced call.

[Tool Calling](https://docs.blobhub.io/blob-types/workflow/workflows/tool-calling.md) covers the route, the results and the loop.

### The answer's shape

Data inputs.

| Route | Value |
| :- | :- |
| `response_format` | `choice`: `text`, `json`, `json_schema` |
| `response_schema` | `message` |
| `output_modalities` | `list` of `choice`: `text`, `image` |
| `output_role` | `text` |
| `output_metadata` | `object` |

* `response_format`: labelled Text, JSON and JSON schema. Defaults to `text` ([The answer format](#the-answer-format)).
* `response_schema`: with `json_schema`, the answer's schema, as the envelope `{"name", "schema", "strict"?}`.
* `output_modalities`: labelled Text and Image. Defaults to `["text"]`. `image` asks the model for images, written as
  session files ([Modalities and Media](https://docs.blobhub.io/blob-types/workflow/workflows/modalities-and-media.md#images-out)).
* `output_role`: the role of the final answer ([A tool loop keeps its roles](#a-tool-loop-keeps-its-roles)). Defaults to
  `assistant`.
* `output_metadata`: merged into the answer's `metadata`; its `role` is the role the final answer is posted with. Empty
  by default.

### Output

A data output.

| Route | Value |
| :- | :- |
| `output` | `message` |

* `output`: the answer: text, `json`, reasoning, tool calls and files, with `model`, `usage`, `finish`, `read` and
  whatever `output_metadata` adds in its `metadata`, except its `role` on the `tool_call` route. Posted as an item
  when wired to a `data.thread`, and written as a value otherwise ([The output](#the-output)).

**On the model, not on chat.** The model and how it is called sit on the
[language model provider](https://docs.blobhub.io/blob-types/workflow/workflows/component-genai-model-language.md): `alias`, `model`,
`allowed_models`, `vendors` and `vendor_settings`; the nine shared settings, `max_output_tokens`, `temperature`,
`top_p`, `top_k`, `stop_sequences`, `seed`, `frequency_penalty`, `presence_penalty` and `reasoning_effort`; and the
language family's `prompt_cache` (`off` or `on`) and `reasoning_summary` (`none` or `auto`). A run can replace the
model and the settings for one run ([Choosing a Model per Run](https://docs.blobhub.io/blob-types/workflow/workflows/choosing-a-model.md)). The
vendors and gateways a provider reaches are on
[Vendors and Gateways](https://docs.blobhub.io/blob-types/workflow/workflows/vendors-and-gateways.md), prompt caching and usage on
[Prompt Caching and Usage](https://docs.blobhub.io/blob-types/workflow/workflows/prompt-caching-and-usage.md).

## What it answers

Chat answers only when there is something to answer: when `current` is sent, or when the history's newest message is
not the model's own answer, a message of role `assistant`; with no `history` wired, chat answers its system message.
The newest message is judged on the roles the selection sends (`history_roles` and `history_skip_roles`), so under the
default selection a `note` posted after an answer, such as a listener's receipt, does not prompt another. Tool results
are stored on a thread as `reply` items but read back as `user` messages
([A thread as history](#a-thread-as-history)), so a history that ends with them is answered.

With `history` wired, nothing in `current`, and a history that ends with the model's own answer or is empty, chat calls
no model, writes nothing and ends on `success`. It posts a `component.output` event whose `attributes.code` is
`nothing_to_answer`, with the message `Nothing to answer: the conversation ends with the model's own answer.`, or, for
an empty history, `Nothing to answer: the conversation is empty.`

* Several messages posted before a run starts are answered together, by one answer.
* A second run started for messages the first already answered does nothing.
* A leg that runs again after its answer was posted to its output thread calls no model. It outputs that answer as
  its first run did, with the same role and metadata, and takes the route its `finish` gives; only its `attributes.id`
  and `attributes.created_at` differ, naming the stored item. It posts a `component.output` event whose
  `attributes.code` is `already_answered`, with `item_id` naming the stored item. An answer found with a part missing
  also carries `metadata.missing_parts` and a placeholder text block in the part's place
  ([parts](https://docs.blobhub.io/blob-types/workflow/workflows/component-data-thread.md#write)).
* With no message at all, it posts the error `No input messages provided` and takes its `failure` route.

## The conversation sent

The request holds, in order: `system`, with its role set to `system`; the history, as the
[history selection](https://docs.blobhub.io/blob-types/workflow/workflows/selecting-a-history.md) chooses it, in the history's own order; then
`current`, unless it is empty: no blocks, or only `text` blocks whose text is empty or whitespace.

A chat node's first call in an execution fixes where its history starts: the anchor, the range's first message and the
window guard's cut. Its later calls in that execution start in the same place, so a post or a newer anchor that arrives
during a [tool loop](https://docs.blobhub.io/blob-types/workflow/workflows/tool-calling.md) does not move the history under it.

### A thread as history

A `data.thread` on `history` reads as a `messages` value of the items the run can see: those posted before its
execution started, and those the execution posted itself
([Thread Component](https://docs.blobhub.io/blob-types/workflow/workflows/component-data-thread.md)). An alias that holds nothing yet reads as an
empty history. Each item becomes one message:

| Item role | Read as |
| :- | :- |
| `reply`, holding no `tool_result` block | `assistant` |
| `reply`, holding `tool_result` blocks | `user` |
| `request` | `user` |
| `note` | `user` |
| Any other role, such as `summary` or `handover` | `user` |
| None, on an item posted without one | `user` |

* A `reply` holding no `tool_result` block: an answer.
* A `reply` holding `tool_result` blocks: tool results travel in a `user` message.
* A `note`: not sent by the default selection, `history_skip_roles: ["note"]`.

Each message carries its item's id and time as `attributes.id` and `attributes.created_at`, and its item's role in
`metadata.role`, which is absent for an item posted without one. The mapping reads nothing but the stored item, so a
thread reads the same on every turn.

### Roles and blocks

* **Roles.** The text of every `system` message, joined by a blank line, becomes the vendor's instructions, and their
  files go at the head of the first `user` turn, or in a `user` turn of their own when there is none. A message of any
  other role than `assistant` is sent as `user`.
* **Turns.** Consecutive messages of one role are sent as one turn, their blocks concatenated and never joined into
  one: vendors that require turns to alternate get them that way, and Gemini refuses a signed part that was merged.
* **Blocks.** A `text` block is sent as text, and a `json` block as text holding its JSON, keys sorted. A `file` block
  is sent as the vendor's media part, the file's bytes in base64
  ([Modalities and Media](https://docs.blobhub.io/blob-types/workflow/workflows/modalities-and-media.md)). `tool_call` and `tool_result` blocks
  take the vendor's own form ([Tool Calling](https://docs.blobhub.io/blob-types/workflow/workflows/tool-calling.md)), and a `reasoning` block goes
  only to the vendor that wrote it ([Reasoning](#reasoning)).
* **A block left out.** Only a `vector` block is left out of the request, with the warning
  `Left out of the request: a vector block in message <n>`. A `file` block the model or its dialect cannot take fails
  the call with `unsupported_media`
  ([When the call fails](https://docs.blobhub.io/blob-types/workflow/workflows/component-genai-model-language.md#when-the-call-fails)). A `file`
  block in an `assistant` turn, on a dialect that takes no media there, is sent as the text
  `[file: <name>, <content type>]`.

### The same on every turn

A dialect renders a stored message the same way on every call. It reads nothing but the message and its files' bytes:
no clock, no ids and no signed URLs, and the JSON the platform writes itself is sorted. It never rewrites an old
turn. The vendors bind reasoning and the prompt cache to the exact history before them, so a conversation's request
starts with the same bytes turn after turn, and only a later start, an anchor's or the window guard's cut, changes that
([Prompt Caching and Usage](https://docs.blobhub.io/blob-types/workflow/workflows/prompt-caching-and-usage.md),
[Selecting a History](https://docs.blobhub.io/blob-types/workflow/workflows/selecting-a-history.md)).

### A call goes with its result

The vendors refuse a tool call whose result is not in the next turn, and a result whose call is not in the turn
before. The order the history is counted in keeps them together
([Selecting a History](https://docs.blobhub.io/blob-types/workflow/workflows/selecting-a-history.md)), but they are still separated by:

* a role filter or a kept role that leaves one of the two out;
* a run that began after a call but before its result was posted, which never sees the result;
* a result posted more than 100 messages after its call, which answers no call;
* a block sent where its turn does not hold its pair, such as a result whose call is not in the thread.

Chat sends each such block as one text block naming it, `[Tool call <id> to <tool> is missing its result.]` or `[Tool
result for call <id> is missing its call.]`, so no vendor refuses the request. A missing id or tool name reads `?`.
After the window guard, the provider posts the `component.warning` `Unpaired tool blocks sent as text: <calls> without a
result and <results> without a call.`, with `attributes.code` `unpaired_tool_blocks`, and `attributes.calls` and
`attributes.results` holding the two counts. The thread is unchanged, and so are the messages sent and `read`; a file
inside a result sent as text is not read. The basic agent sends no such text and posts no such warning. `logic.copy` and
`thread_messages` return their selection as it is.

### The window guard

Before each call to a catalog model, chat estimates the request (the system message, the tools, the history,
`current` and `max_output_tokens`) against the model's context window in
[the catalog](https://docs.blobhub.io/blob-types/workflow/workflows/component-genai-model-language.md#the-catalog).

* **With `trim`**, the default, a request that does not fit loses its oldest whole turns after the anchor, a turn
  running from a request to the next, until it fits. The provider then posts the `component.warning`
  `History trimmed to fit <model>'s context window: <n> messages left out.` The system message, the anchor, kept
  messages, `current` and the newest turn are never left out.
* **When those alone do not fit**, or with `fail` when the request does not fit, the call fails before anything is
  sent: `The request needs about <estimate> tokens; <model>'s context window is <window>.`
* **A model the catalog does not list** is never trimmed, since its window is unknown; a request too long for it meets
  the vendor's own refusal.

The guard is a last resort: a long conversation is bounded with an anchor. How the estimate counts is on
[Selecting a History](https://docs.blobhub.io/blob-types/workflow/workflows/selecting-a-history.md).

### `current` is for this call only

Chat sends `current` after the history and never posts it, so it does not join the conversation. On a conversation it
stays unwired, because the person's post is already the end of the history. It carries what shapes one answer without
joining the conversation: a summarizer's instruction, a judge's rubric, the passages a search retrieved for this
question. A flow with no thread passes its prompt there.

## Reasoning

Every dialect writes the model's reasoning as `reasoning` blocks: OpenAI's reasoning items, Anthropic's thinking,
redacted thinking included, Gemini's thoughts, and the reasoning a gateway returns.

* **`reasoning_summary`**, a setting of the language model provider, decides a block's `text`. With `auto`, it holds
  the model's summary of its reasoning; with `none`, the default, the block holds only what must go back to the vendor
  ([Settings](https://docs.blobhub.io/blob-types/workflow/workflows/component-genai-model-language.md#settings)). Through `openrouter`, a run
  with `none` and a `reasoning_effort` still reasons, and the reasoning text the gateway returns is streamed and stored.
* **`vendor_data`** holds what the vendor needs back on a later turn, on a `reasoning` block or any other, and records
  who wrote it: `{"vendor", "model", "dialect", "data"}`. A call sends it only to the vendor and dialect that wrote
  it, and leaves out a `reasoning` block another vendor wrote. When a run names another vendor's model
  mid-conversation, the history still goes as text, files, tool calls and results.
* **A Gemini model continuing another vendor's tool loop.** Gemini 3 refuses a request in which the first tool call of
  a step of the current turn has no thought signature. For a model on the `gemini` vendor, BlobHub sends Google's
  documented placeholder `skip_thought_signature_validator` as the signature of the first call of each step that has
  none, whoever made it: a call another vendor made, or one of its own calls stored without one. The current turn is
  everything after the newest run of `user` messages that holds no tool result, or the whole conversation when there is
  none. A message sent right after the results, such as `current` or a post made during the call, joins them and starts
  nothing. Each run of `assistant` messages in the turn is a step. Gemini's own signatures are kept, and a step's later
  calls and the steps of earlier turns are sent as they are. A Gemini model reached through OpenRouter or Vercel is
  never sent it. Google notes the placeholder can lower the quality of the answer.
* **Only from the same start.** An answer's reasoning goes back only when its `read.from` is the first history message
  of this request, compared as they are, absent matching absent, so over a `data.messages` history whose messages
  carry no ids it always goes back. Otherwise that answer's `reasoning` blocks and every `vendor_data` are left out,
  and it goes as text, files, tool calls and results. A new anchor moves the start once; a negative `history_from`
  moves it on every run ([Selecting a History](https://docs.blobhub.io/blob-types/workflow/workflows/selecting-a-history.md)).

## The answer format

`response_format` asks the model for text, for JSON, or for JSON that follows `response_schema`. Each dialect asks in
its own way ([Vendors and Gateways](https://docs.blobhub.io/blob-types/workflow/workflows/vendors-and-gateways.md) names the dialect of each
vendor and gateway):

* `openai_responses`:
  * `json`: `text.format`: `{"type": "json_object"}`.
  * `json_schema`: `text.format`: `{"type": "json_schema", "name", "schema", "strict"}`, from the envelope.
* `openai_chat`:
  * `json`: `response_format` of type `json_object`.
  * `json_schema`: `response_format` of type `json_schema`, holding the whole `response_schema` envelope.
* `anthropic_messages`:
  * `json`: nothing. Anthropic has no schema-less JSON mode, and the provider posts the warning
    `"response_format" is specified but is not currently supported`.
  * `json_schema`: `output_config.format`: `{"type": "json_schema", "schema"}`.
* `gemini_generate`:
  * `json`: `response_mime_type` of `application/json`.
  * `json_schema`: `application/json`, with the `schema` of the `response_schema` envelope.

**An answer that parses is a `json` block.** With `json` or `json_schema`, an answer whose text parses as JSON is
written as one `json` block in place of its text blocks. One that does not parse stays text, with the warning
`The answer is not valid JSON; kept as text`.

**An empty schema is refused for every vendor.** With `json_schema`, a `response_schema` that is not set, or whose
envelope holds no `schema` object or an empty one (`{}`), fails the call with the `component.error`
`schema_required_in_json_schema_mode` before any vendor is called, and chat takes its `failure` route.

## The output

`output` is one message, with the role `assistant` unless `output_role` says otherwise on a final answer
([A tool loop keeps its roles](#a-tool-loop-keeps-its-roles)). It holds what the model answered: text, a `json` block
for a structured answer, `reasoning` blocks, `tool_call` blocks, and a `file` block for each image the model drew, at
its place among the text ([Modalities and Media](https://docs.blobhub.io/blob-types/workflow/workflows/modalities-and-media.md#images-out)).

Its `metadata` records the call:

* `model`: `{"id": <model id>}`: the model that answered.
* `usage`: the call's usage ([Prompt Caching and Usage](https://docs.blobhub.io/blob-types/workflow/workflows/prompt-caching-and-usage.md#usage)).
* `finish`: why the answer ended: `stop`, `tool_call`, `length` or `refused`.
* `read`: `{"from", "through", "count"}`: the ids of the first and last history messages the request held, and how many
  it held. `from` and `through` are left out when that message has no id.

`output_metadata` is merged under these keys: it cannot replace `model`, `usage`, `finish` or `read`, and its `part` and
`missing_parts` are dropped, since parts belong to the post. Its `role` is the role a final answer is posted with.

Each dialect's own ending maps to `finish`:

* `openai_responses`:
  * `stop`: `completed`.
  * `tool_call`: a `function_call` item.
  * `length`: incomplete, `max_output_tokens`.
  * `refused`: a `refusal` part, incomplete `content_filter`.
* `openai_chat`:
  * `stop`: `stop`.
  * `tool_call`: `tool_calls`.
  * `length`: `length`.
  * `refused`: `content_filter`.
* `anthropic_messages`:
  * `stop`: `end_turn`, `stop_sequence`.
  * `tool_call`: `tool_use`.
  * `length`: `max_tokens`.
  * `refused`: `refusal`.
* `gemini_generate`:
  * `stop`: `STOP`.
  * `tool_call`: a `function_call` part.
  * `length`: `MAX_TOKENS`.
  * `refused`: a safety reason, or no candidate.

With `finish` `tool_call`, chat ends on its `tool_call` route; otherwise on `success`. It writes its output on both.

### An answer at the output cap

An answer with `finish` `length` stopped at the model's output cap, `max_output_tokens`. When it holds anything, text,
`json`, a tool call or an image, it is the answer, written and routed as above, and the provider first posts the
`component.warning`
`The reply was cut at the output cap: <model> used all of its <n> output tokens. Raise max_output_tokens for a complete
reply.`

When it holds nothing but `reasoning` blocks and blank text, the model spent its whole cap thinking, and chat writes
nothing, posts nothing and takes its `failure` route. The provider posts the call's `component.output`, with its usage,
then the `component.error`
`<model> used all of its <n> output tokens without writing a reply. Raise max_output_tokens, or lower reasoning_effort
or the thinking budget.`
`<n>` is the answer's `usage.output_tokens`; when the vendor reports none, the message reads `all of its output tokens`.
An empty answer posted to a thread would become the newest answer, so the next run would read the conversation as
answered.

A leg that runs again after its answer was stored takes the route that answer's `finish` gives, as before; an empty
answer stored at the cap before this rule keeps `success`.

### A tool loop keeps its roles

`output_role` and the `role` of `output_metadata` apply to the final answer only. An answer on the `tool_call` route
takes neither: it stays an `assistant` message, is posted as `reply`, and keeps every other key of `output_metadata`.
The results, posted by the component that runs the tools, are `reply` items too unless that component gives them a
role. So the loop's calls and results read back as calls and results whatever role the chat outputs.

The route decides, not the content. An answer that holds a call but ends with `finish` `length` takes `success`, so it
is final and carries the chat's role. When that role is not `reply`, a listener filtered on it (`item.role` of
`thread.item_posted`) hears only the loop's final answer. With the defaults every item of the loop is `reply`, and the
filter matches the calls and results too.

### Where the answer goes

* **`output` wired to a `data.thread`:** the answer is posted as an item of that thread, with the `role` of
  `output_metadata` when it gives one, otherwise `reply` for an `assistant` answer. An answer on `tool_call` is always
  `reply` ([A tool loop keeps its roles](#a-tool-loop-keeps-its-roles)). See the
  [Thread Component](https://docs.blobhub.io/blob-types/workflow/workflows/component-data-thread.md). While the model writes, the answer is
  streamed as a partial message to the connections following the session, under the id the item will have
  ([Streaming](https://docs.blobhub.io/blob-types/workflow/workflows/streaming.md)).
* **`output` wired to another data component:** the answer is written as a value, and nothing is posted. A
  session-persisted value is streamed under its alias while the model writes; an execution-persisted one streams
  nothing.
* **A stopped call** writes nothing and posts nothing.

## Refusals and failures

**A refusal is an answer.** A vendor's refusal, such as Anthropic's `refusal` stop reason, a content filter or
Gemini's blocked prompt, is written as the answer with whatever content arrived, its `metadata.finish` `refused`. The
provider posts a `component.warning` naming the vendor's category, and chat ends on `success`.

A failed call writes nothing, and chat takes its `failure` route. Causes that come from chat's own ports and run:

* no message at all: the error `No input messages provided`;
* `json_schema` with no schema, or an empty one: the error `schema_required_in_json_schema_mode`, before the call
  ([The answer format](#the-answer-format));
* a request over the model's window: `context_exceeded` ([The window guard](#the-window-guard));
* a tool without a `name` or an object `parameters`, named by its index;
* `image` in `output_modalities` on a dialect that gives none, before the call:
  `output_modalities: anthropic gives no images`;
* the execution stopping while the answer streams: the provider posts the `component.warning`
  `The execution is stopping: the answer was discarded and nothing was written.` and takes `failure`
  ([Streaming](https://docs.blobhub.io/blob-types/workflow/workflows/streaming.md)).

A `data.thread` on `history` whose alias holds another kind of object fails the node. The provider's causes (a
missing credential, the vendor's error, a timeout, a file the call cannot send, an answer that reached the output cap
empty) are on the language model page:
[When the call fails](https://docs.blobhub.io/blob-types/workflow/workflows/component-genai-model-language.md#when-the-call-fails). The last is
also under [An answer at the output cap](#an-answer-at-the-output-cap).

### Checks

`check_definition` reports these. Prepare runs it before every run, and a definition that fails it ends the run with
`flow.error` `Workflow definition check failed`.

* `tools` holds a list and nothing is connected to `tool_call`:
  `tool_call: the flow holds tools, so the tool_call route must be connected`.
* A tool lacks a `name` or `parameters`: an error naming its index.
* The provider's catalog model lacks what chat uses, an error in its `model` port:
  `model: <id> does not do tools, which its consumers need` when `tools` holds any, and
  `model: <id> gives no image, which <consumer> asks for` when `output_modalities` holds `image`. A run that names such
  a model for the provider by its alias is refused
  ([Choosing a Model per Run](https://docs.blobhub.io/blob-types/workflow/workflows/choosing-a-model.md)).

## Events

Chat's events are `component.*` events of the
[execution log](https://docs.blobhub.io/blob-types/workflow/workflows/execution-events.md):

* **One `component.output` per call**, posted by the provider. Its `attributes.model` names the model that ran, as
  `{"id", "chosen_by"}`, and its `attributes.usage` the call's usage, both stored whether or not the session logs
  data. Its `data` holds the `request` sent and the vendor's `response`, every string over 4,096 characters that is a
  `data:` URL or base64 replaced by `"<elided: <n> characters>"`
  ([Which model ran](https://docs.blobhub.io/blob-types/workflow/workflows/choosing-a-model.md#which-model-ran)).
* **`component.warning`s**, before the call or about its answer.
* **`component.error`** for a failed call.

Seven outcomes carry a code in `attributes.code`, stored whether or not the session logs data:

| Code | Event | Then |
| :- | :- | :- |
| `nothing_to_answer` | `component.output` | No call; `success`. |
| `already_answered` | `component.output` | No call; the stored answer is output. |
| `history_trimmed` | `component.warning` | The call goes on. |
| `unpaired_tool_blocks` | `component.warning` | The call goes on. |
| `context_exceeded` | `component.error` | No call; `failure`. |
| `cut_at_output_cap` | `component.warning` | The cut answer is output. |
| `empty_at_output_cap` | `component.error` | Nothing is output; `failure`. |

The message and attributes of each:

* `nothing_to_answer`: `Nothing to answer: the conversation ends with the model's own answer.`, or
  `Nothing to answer: the conversation is empty.`
* `already_answered`: with `attributes.item_id`;
  `Already answered: the answer this step posted before it was retried is returned as stored.`
* `history_trimmed`: with `attributes.left_out`;
  `History trimmed to fit <model>'s context window: <n> messages left out.`
* `unpaired_tool_blocks`: with `attributes.calls` and `attributes.results`;
  `Unpaired tool blocks sent as text: <calls> without a result and <results> without a call.`
* `context_exceeded`: with `attributes.estimate` and `attributes.window`;
  `The request needs about <estimate> tokens; <model>'s context window is <window>.`
* `cut_at_output_cap`:
  `The reply was cut at the output cap: <model> used all of its <n> output tokens. Raise max_output_tokens for a
  complete reply.`
* `empty_at_output_cap`, after the call's `component.output`:
  `<model> used all of its <n> output tokens without writing a reply. Raise max_output_tokens, or lower
  reasoning_effort or the thinking budget.`

Among the other warnings:

* Settings are left out: one warning naming each setting left out and why
  ([Settings](https://docs.blobhub.io/blob-types/workflow/workflows/component-genai-model-language.md#settings)).
* `tool_choice` is `required` on a model that refuses a forced call:
  `tool_choice "required" is not supported by <id>: sent "auto"`
* The request leaves a block out: `Left out of the request: a vector block in message <n>`
* A structured answer does not parse: `The answer is not valid JSON; kept as text`
* The vendor refuses: a warning naming the vendor's category.

The warnings a provider posts about a run's model and settings are listed in
[Warnings while it runs](https://docs.blobhub.io/blob-types/workflow/workflows/choosing-a-model.md#warnings-while-it-runs).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.