genai.chat chooses what it sends from its
history with parameters of its own, the history selection: roles, an anchor, a range, kept roles and a fit. Nothing
in the platform knows what a summary is. A rolling summary, a running ledger, a shift handover, a fresh start and a
pinned brief are each a few settings of the same parameters (Built on the selection).
The examples on this page use Halden Systems’ release thread, releases/t2-firmware-2.2. The release team posts its
questions, build results and sign-offs there, a chat answers them, a listener’s receipts land there as notes, and a
second chat keeps a rolling summary of it all (A rolling summary, step by step).
After two weeks it holds several hundred items, and no turn should send them all.
What a message carries
The selection reads three things on a message:- A role, any role.
metadata.roleis whatever its writer declares. The platform usesrequest(someone should act on this),reply(an answer; nobody has to act) andnote(bookkeeping, such as a listener’s receipt), and reservesresult. Any other role, such assummary,handover,brieforledger, is kept as written. A message read from a thread carries its item’s role inmetadata.role. A message without one is selected by the role it would be posted with:replyfor anassistantmessage or ausermessage holding onlytool_resultblocks, andrequestfor any other (the mapping). - Its id and time, as
attributes.idandattributes.created_at, when it is read from a thread. - What it read, on an answer. Every answer chat writes records
metadata.read:fromandthrough, the ids of the first and last history messages its request held, andcount, how many it held.fromandthroughare left out when that message has no id. It is a record anyone can read, and the anchor, the window guard’s estimate and the reasoning rule below use it.
The parameters
history_roles: send only messages of these roles.history_skip_roles: never send messages of these roles.history_anchor: the newest message of this role starts what is sent (An anchor is a hard edge).history_from: the start of a range over the messages after the anchor’s edge, counted as a Python slice counts, negative from the end.history_to: the end of that range, not included:-6leaves out the newest six.history_keep: send messages of these roles even where the anchor or the range leaves them out.history_fit: what happens when the request would not fit the model’s window (The window guard).
read.from and read.through, and so a summary’s read.through, name
messages of the request in that order. A result counts with its call only within the 100 messages after the call, and a
call whose result a run does not see moves nothing. The thread itself, its items’ order and ids, and what the thread
widget shows do not change.
They apply in this order:
- Roles. A message of a skipped role, or of a role outside
history_roleswhen that is set, is not sent. An anchor whose role is skipped still marks where the history starts. - The anchor. The newest message of
history_anchor’s role is the anchor. Its edge is the message itsread.throughnames. Every message up to and including the edge is left out, with every other message of the anchor’s role, and the anchor stands in their place. An anchor withoutread, or whoseread.throughnames no message of this history, as one a person or a program posted, is its own edge: the history starts at itself. With no message of that role, nothing is left out. - The range.
history_fromandhistory_toslice the messages after the edge that the roles let through. The anchor is not counted, and it is sent unless its role is skipped. - Kept roles. A message of a
history_keeprole that the anchor or the range left out is sent anyway, in the history’s order, unless its role is skipped. - The fit: the window guard.
current follows the last of them.
Turns. A turn starts at a request and runs to the next one: a question, then the answers, tool calls and tool
results that follow it. Messages after the edge and before its first request form a turn of their own. The range and
the window guard cut only between turns:
- A range whose first message is not a turn’s request starts at that turn’s request, so a tool result is never sent without its call.
- A range whose end falls inside a turn ends before that turn’s request, so
history_to: -6leaves out at least the newest six. - An anchor’s edge that falls inside a turn, when the first message sent after it is not a request, moves back to
before that turn’s request; when no request precedes it, the edge moves before the first message sent, and leaves
nothing out. The turn is sent whole, so the messages of it the anchor’s writer did read are sent again. The edge
never covers a message posted after
read.through. - The window guard leaves out whole turns.
An anchor is a hard edge
An anchor is a hard edge: a message the anchor’s writer read is never sent again, even where the range would reach it, except in a turn the edge fell inside. Over the release thread, whose newest summary read all but the last 30 items,history_from: -100 sends the summary and those 30. Only history_keep brings a message back across the edge. A flow
that needs everything, an export or an audit, sets no anchor.
An anchor resumes where its writer stopped reading, not where it was posted. A summary is posted after the items
it read, and the thread keeps growing while it is written. The items its writer did not read sit before it in the
thread but after its read.through, so they are sent after it: the newest six it left out with history_to: -6, or a
build report posted while the summary was being written. Position would lose them.
The release thread, read with history_anchor: summary when the release manager’s next question starts a run (notes,
which the default history_skip_roles leaves out, are not shown):
Summary 1 is left out with the rest of the anchor’s role.
history_keep: ["brief"] would bring back the release’s
first post if it had the role brief, from before the edge, sent before summary 2.
A start fixed for the run
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 tool loop never moves them, even when a newer anchor or a post arrives between two calls. Over adata.messages history whose messages carry no ids, the start is kept by position, which
holds while the value only grows at its end, as it does in a tool loop.
logic.copy and thread_messages select afresh on every call
(One selection, in three places).
The window guard
Before each call to a model the catalog lists, chat estimates the request against the model’s context window. The estimate counts:- the system message, the tools, the history that is sent,
current, and themax_output_tokensthe call uses, 0 when it is unset; - four characters a token over each block’s JSON text;
- each file at its dialect’s estimate: by default 1,600 tokens for an image, and 20, 8 and 2 tokens a KiB for a PDF, audio and video;
- in place of characters, the newest answer’s recorded
metadata.usage.input_tokens, when this model wrote that answer and itsread.fromandread.throughare both in the request: it stands for the system message, the tools and the messages fromread.fromthroughread.through, and the rest is counted by characters.
- With
trim, the default, the oldest whole turn after the anchor is left out, then the next, until the request fits. The provider then posts thecomponent.warningHistory trimmed to fit <model>'s context window: <n> messages left out., withattributes.codehistory_trimmedandattributes.left_out, and the call goes on. 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 at all, the call fails before anything is sent, with thecomponent.errorThe request needs about <estimate> tokens; <model>'s context window is <window>., itsattributes.codecontext_exceeded,attributes.estimateandattributes.window. Chat takes itsfailureroute. - 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.
What moving the start costs
The vendors bind reasoning and the prompt cache to the history before them. Stored messages still render the same on every turn: the platform rewrites nothing, and a selection only starts later (The same on every turn).- Reasoning goes back on an answer only when its
read.fromis this request’s first history message, compared as they are, absent matching absent, so over adata.messageshistory without ids it always goes back. Otherwise the answer goes back as text, files, tool calls and results, as it does to another vendor (Reasoning). - An anchor moves the start once for each new anchor. Where a prompt cache is at work, the turn after a new anchor writes it anew, and the turns after that read it.
- A negative
history_frommoves the start on every run, so such a flow reads no cache across turns and sends back no earlier reasoning. The window guard’s cut does the same while it trims.
current is for this call only
Chat sends current after the history and never posts it, so it does not join the conversation: no later turn reads
it from the thread. 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.
An empty current, with no blocks, or only text blocks whose text is empty or whitespace, is not sent. Chat answers
whenever current is sent, which is why a summarizer posts a summary every time the flow reaches it. Without
current, a chat with a history answers only when that history is not empty and its newest message is not the
model’s own answer; otherwise it calls no model and writes nothing
(What it answers).
One selection, in three places
The same parameters, under three sets of names:genai.chatselects itshistoryand fits it to the model’s window.logic.copyselects itsinput, so a flow can hand any component a selected history: atext.render_template, or adata.messageskept for review.thread_messages(alias, roles=None, skip_roles=None, anchor=None, from_=None, to=None, keep=None)takes the same names as keyword arguments. The range’s start isfrom_, becausefromis a Python keyword. An argument left out takes its default, so notes are left out unlessskip_roles=[]reads them.
history_keep set, the whole thread is read. Any other component that reads a
data.thread gets the thread whole, notes left out.
Built on the selection
- A rolling summary: a summarizer chat reads with
history_anchor: summaryandhistory_to: -6, has its instruction incurrent, and posts its answer withoutput_metadata: {role: summary}; the answering chat reads withhistory_anchor: summary. Below, and the gallery’s Launch Pulse - A running ledger: as a summary, with a
response_schema: each run reads the last ledger and what followed it, and writes the next. Roleledger - A shift handover: the shift’s last run posts a
handover; the next shift’s chat reads withhistory_anchor: handover - A fresh start in one thread: a post with the role
boundary; chat reads withhistory_anchor: boundaryandhistory_skip_roles: ["note", "boundary"] - A pinned brief: the task’s first post has the role
brief, andhistory_keep: ["brief"]sends it past every anchor and range - A sliding window:
history_from: -20, at the price in What moving the start costs - A router or a classifier:
history_roles: ["request"]andhistory_from: -1 - Notes one chat keeps from another: a chat posts its scratch work with the role
scratch.planner, and the other chats skip that role - An export:
logic.copywith no anchor andskip_roles: []
A rolling summary, step by step
The summarizer’s input is the previous summary and the items since it, and its output is the next summary. What a summary holds, and how the old one and the new items combine, is its instruction’s to say: rewrite it whole, add a dated section, or carry counts forward. The platform concatenates nothing. Halden’s release flow runs each time the release team posts in the conversation widget. Its three steps:- Due? runs the program below. Its
dueroute leads to Summarize, and itsskiproute to Answer. - Summarize has
historyandoutputwired to thedata.threadreleases/t2-firmware-2.2;history_anchor: summary;history_to: -6;currentholds the instruction, “Fold the previous summary and the items since into the next: open blockers, test results and sign-offs.”;output_metadata: {role: summary}. It goes on to Answer. - Answer has
historyandoutputwired to the samedata.thread;history_anchor: summary.
- The first time, there is no summary: the summarizer reads every item but the newest six and writes summary 1,
whose
read.throughnames the newest item it read, the seventh-newest when the cut falls between turns. - The answering chat sends summary 1 and then every item after its
read.through: the six it left out and anything posted since. - The next time, the summarizer reads summary 1 and the items after its
read.throughbut the newest six, and writes summary 2. Summary 1 is never sent again. - Whether a summary is due is the flow’s to decide, before the summarizer, as for any component: a chat whose
currentis sent answers every time the flow reaches it, so the summarizer posts a summary on every call. Due? reads what the next summary would cover: the items after the newest summary’sread.through, the summary itself left out. It routesdueto the summarizer when they pass a count, andskippast it otherwise. Both routes are wired, because a route with no connection fails the execution.
Due? gate is one logic.code program. It reads the thread with
thread_messages, anchored on summary with summary and
note skipped, so it counts what follows the newest summary’s edge and not the summary itself, and routes with
set_result:

