genai.model.language, and writes the model’s answer
as one message. Wired to a data.thread on both history and
output, it reads a conversation and posts its answer into it
(Messages and Threads).
Ports
Agenai.chat has one flow input, which starts it, and the ports below, grouped by what they do.
Flow
The flow outputs.Model
A provider input.model: required. The model that answers, with its credentials and settings. A run may name another (Choosing a Model per Run).
Content
Data inputs.system: the instructions, sent first with its role set tosystem. Every block reaches the model: its text becomes the vendor’s instructions, and its files go at the head of the firstuserturn. The editor fills in an empty text message.history: the conversation so far, read from the one data component wired here: adata.threadfor a conversation, or adata.messagesfor 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 roleuser.
History selection
Data inputs.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 itsread.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’sread.through(after the anchor itself when it has noread), 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:-6leaves 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;failfails the call (The window guard).
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.
Tools
Data inputs.tools: each object holdsname(text, required),description(text),parameters(object, required) andstrict(boolean). The tools the model may call;parametersis a JSON schema. Empty by default. A catalog model must dotoolswhen the list holds any.tool_choice: labelled Auto, None and Required. Defaults toauto. Whether the model may call a tool, must not, or must;requiredbecomesauto, with a warning, on a model that refuses a forced call.
The answer’s shape
Data inputs.response_format: labelled Text, JSON and JSON schema. Defaults totext(The answer format).response_schema: withjson_schema, the answer’s schema, as the envelope{"name", "schema", "strict"?}.output_modalities: labelled Text and Image. Defaults to["text"].imageasks the model for images, written as session files (Modalities and Media).output_role: the role of the final answer (A tool loop keeps its roles). Defaults toassistant.output_metadata: merged into the answer’smetadata; itsroleis the role the final answer is posted with. Empty by default.
Output
A data output.output: the answer: text,json, reasoning, tool calls and files, withmodel,usage,finish,readand whateveroutput_metadataadds in itsmetadata, except itsroleon thetool_callroute. Posted as an item when wired to adata.thread, and written as a value otherwise (The output).
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). The
vendors and gateways a provider reaches are on
Vendors and Gateways, prompt caching and usage on
Prompt Caching and Usage.
What it answers
Chat answers only when there is something to answer: whencurrent 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), 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
finishgives; only itsattributes.idandattributes.created_atdiffer, naming the stored item. It posts acomponent.outputevent whoseattributes.codeisalready_answered, withitem_idnaming the stored item. An answer found with a part missing also carriesmetadata.missing_partsand a placeholder text block in the part’s place (parts). - With no message at all, it posts the error
No input messages providedand takes itsfailureroute.
The conversation sent
The request holds, in order:system, with its role set to system; the history, as the
history selection 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 does not move the history under it.
A thread as history
Adata.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). An alias that holds nothing yet reads as an
empty history. Each item becomes one message:
- A
replyholding notool_resultblock: an answer. - A
replyholdingtool_resultblocks: tool results travel in ausermessage. - A
note: not sent by the default selection,history_skip_roles: ["note"].
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
systemmessage, joined by a blank line, becomes the vendor’s instructions, and their files go at the head of the firstuserturn, or in auserturn of their own when there is none. A message of any other role thanassistantis sent asuser. - 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
textblock is sent as text, and ajsonblock as text holding its JSON, keys sorted. Afileblock is sent as the vendor’s media part, the file’s bytes in base64 (Modalities and Media).tool_callandtool_resultblocks take the vendor’s own form (Tool Calling), and areasoningblock goes only to the vendor that wrote it (Reasoning). - A block left out. Only a
vectorblock is left out of the request, with the warningLeft out of the request: a vector block in message <n>. Afileblock the model or its dialect cannot take fails the call withunsupported_media(When the call fails). Afileblock in anassistantturn, 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, Selecting a History).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), 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.
[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.
- 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 thecomponent.warningHistory trimmed to fit <model>'s context window: <n> messages left out.The system message, the anchor, kept messages,currentand the newest turn are never left out. - When those alone do not fit, or with
failwhen 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.
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 asreasoning 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’stext. Withauto, it holds the model’s summary of its reasoning; withnone, the default, the block holds only what must go back to the vendor (Settings). Throughopenrouter, a run withnoneand areasoning_effortstill reasons, and the reasoning text the gateway returns is streamed and stored.vendor_dataholds what the vendor needs back on a later turn, on areasoningblock 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 areasoningblock 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
geminivendor, BlobHub sends Google’s documented placeholderskip_thought_signature_validatoras 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 ofusermessages that holds no tool result, or the whole conversation when there is none. A message sent right after the results, such ascurrentor a post made during the call, joins them and starts nothing. Each run ofassistantmessages 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.fromis the first history message of this request, compared as they are, absent matching absent, so over adata.messageshistory whose messages carry no ids it always goes back. Otherwise that answer’sreasoningblocks and everyvendor_dataare left out, and it goes as text, files, tool calls and results. A new anchor moves the start once; a negativehistory_frommoves it on every run (Selecting a History).
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 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_formatof typejson_object.json_schema:response_formatof typejson_schema, holding the wholeresponse_schemaenvelope.
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_typeofapplication/json.json_schema:application/json, with theschemaof theresponse_schemaenvelope.
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). 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).
Its metadata records the call:
model:{"id": <model id>}: the model that answered.usage: the call’s usage (Prompt Caching and Usage).finish: why the answer ended:stop,tool_call,lengthorrefused.read:{"from", "through", "count"}: the ids of the first and last history messages the request held, and how many it held.fromandthroughare 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: afunction_callitem.length: incomplete,max_output_tokens.refused: arefusalpart, incompletecontent_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: afunction_callpart.length:MAX_TOKENS.refused: a safety reason, or no candidate.
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 withfinish 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
outputwired to adata.thread: the answer is posted as an item of that thread, with theroleofoutput_metadatawhen it gives one, otherwisereplyfor anassistantanswer. An answer ontool_callis alwaysreply(A tool loop keeps its roles). See the Thread Component. 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).outputwired 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’srefusal 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_schemawith no schema, or an empty one: the errorschema_required_in_json_schema_mode, before the call (The answer format);- a request over the model’s window:
context_exceeded(The window guard); - a tool without a
nameor an objectparameters, named by its index; imageinoutput_modalitieson 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.warningThe execution is stopping: the answer was discarded and nothing was written.and takesfailure(Streaming).
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. The last is
also under 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.
toolsholds a list and nothing is connected totool_call:tool_call: the flow holds tools, so the tool_call route must be connected.- A tool lacks a
nameorparameters: an error naming its index. - The provider’s catalog model lacks what chat uses, an error in its
modelport:model: <id> does not do tools, which its consumers needwhentoolsholds any, andmodel: <id> gives no image, which <consumer> asks forwhenoutput_modalitiesholdsimage. A run that names such a model for the provider by its alias is refused (Choosing a Model per Run).
Events
Chat’s events arecomponent.* events of the
execution log:
- One
component.outputper call, posted by the provider. Itsattributes.modelnames the model that ran, as{"id", "chosen_by"}, and itsattributes.usagethe call’s usage, both stored whether or not the session logs data. Itsdataholds therequestsent and the vendor’sresponse, every string over 4,096 characters that is adata:URL or base64 replaced by"<elided: <n> characters>"(Which model ran). component.warnings, before the call or about its answer.component.errorfor a failed call.
attributes.code, stored whether or not the session logs data:
The message and attributes of each:
nothing_to_answer:Nothing to answer: the conversation ends with the model's own answer., orNothing to answer: the conversation is empty.already_answered: withattributes.item_id;Already answered: the answer this step posted before it was retried is returned as stored.history_trimmed: withattributes.left_out;History trimmed to fit <model>'s context window: <n> messages left out.unpaired_tool_blocks: withattributes.callsandattributes.results;Unpaired tool blocks sent as text: <calls> without a result and <results> without a call.context_exceeded: withattributes.estimateandattributes.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’scomponent.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.
- Settings are left out: one warning naming each setting left out and why (Settings).
tool_choiceisrequiredon 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.

