Skip to content
AI Portal Docs
On this page Assembling the turn 1/10

Every model call in a turn reads the same stack: the agent’s instructions with the runtime’s contract, short-term memory, then your new message with its attachments. This page walks the stack from bottom to top, then explains how a long conversation is compacted and how the result is drawn on screen.

Key rules

  1. Later layers win: portal floor → author instructions → /slug skills → skill catalogue.
  2. Short-term memory is rebuilt from the transcript on every call: 20 turns, 8 calls per turn, tool output from the 3 closest.
  3. Thinking never enters memory; only what the agent did and said does.
  4. At 85% of the context window the turn compacts into a summary plus the last four messages, and carries on.
  5. Only a text block can be the answer.

Assembling the turn

OrderLayerContent
1Portal floorWho the assistant is and how it talks.
2Author instructionsThe agent author’s instructions.
3Selected skillsSkills chosen with leading /slug commands, folded in whole.
4Skill catalogueThe other bound skills, each as a name and one sentence on when it applies; the model loads the one it needs.
5Short-term memoryRecent turns rebuilt from the transcript (below).
6New messageYour message plus its attachments.

Effort

The agent carries an effort levelThinking effortMức suy nghĩHow long the model may think before answering. More effort can help with hard questions, but it takes longer and costs more.Open in glossary, and you may change it for one message. The winning level is recorded on the turn, so a resumed turn keeps it and the composer shows it when the conversation is reopened. A model that cannot reason at depth ignores it. Levels and what they cost are on the agentic loop.

Attachments

An attachment is either a document or a picture, decided once at upload. The full pipeline is on Knowledge pipeline; in the prompt:

  • A document appears as a manifest entry: filename and type, attachment id, reading progress, unreadable pages and the first twenty section headings. A finished document of at most 6,000 characters is placed in the message whole; anything longer is read with read_document and searched with search_attachments.
  • A picture is handed to the model as itself, reduced first if it is larger than the provider looks at, and the message names the reduced size. A message with a picture needs a model that can see; otherwise the turn is refused before anything is recorded, naming the model.
  • On later turns every earlier document replays as its manifest with its current status, inline text replays within a shared budget (newest first), and only the few most recent picture-bearing messages resend their pictures. Older ones say in words that the picture is gone.

Instructions

The skill catalogue comes from the agent, narrowed to what you can see and what is published; a resumed turn gets the same list.

The composer writes your selections into the message, for example /market-research /fact-check before the request. Before the turn opens, the backend:

  1. Resolves each distinct slug within your organisation.
  2. Checks visibility and active status. One rejected skill rejects the whole request.
  3. Records a SKILL_SELECT trace entry with each activated skill’s id; a resume uses those ids and checks visibility again.
  4. Leaves selected skills out of the catalogue, since their instructions are already loaded.

Short-term memory

Short-term memory is the recent action log, rebuilt from the transcript and read in full on every call. A past turn’s tool calls come back as tool calls: the call in an assistant message and the result in the next. Thinking and pre-tool narration never enter it.

BoundValue
Turns replayed20
Calls replayed per turn8
Turns whose tool output is replayedThe 3 closest
Each replayed resultA few hundred characters, plus a reference to fetch the whole
Strings inside argumentsCut
  • Older turns keep each call’s name, arguments and outcome but lose the result and the failure message. A result that crossed whole carries no reference.
  • Every replayed call is answered; one that never returned gets an answer saying so, because the model API refuses an assistant message holding an unanswered call.
  • A cut-off turn still leaves what it wrote and the calls it ran.
  • Two adjacent prose entries never share a role, and an entry carrying a tool’s answer is never merged into.

Which calls hold their place and what a result line says at each distance are on Tool rules.

Context compaction

A turnTurnLượtEverything between sending a message and getting the answer: checks, model calls, tool use, pauses for you, and the reply. It keeps running if you close the tab.Open in glossary whose history no longer fits is summarised. A compaction replaces everything before it with a summary. Later turns replay the newest summary first, then whatever came after it; the 20-turn limit bounds only that second part. The summary opens by naming the turns it covers, which always start at turn 1, because each compaction summarises the previous summary together with what followed.

A turn compacts on its own before a model call whose projected input reaches 85% of the model’s context window, and again when the gateway reports an overflow. It then continues the same turn: its message list becomes the summary followed by the last four messages verbatim, shifted so the tail never opens on a tool result or on a call without its result.

A summary that fails before a call is logged and the call goes ahead. One that fails after an overflow fails the turn.

Type /compact, optionally followed by instructions for the summary. That opens a turn which summarises the history and ends without entering the agent loop. It is refused:

  • while the conversation’s latest turn is running or paused;
  • when nothing has been written since the last compaction;
  • when the message carries attachments.

While a turn runs the composer refuses to send /compact, because steering would hand it to the running turn as text.

What the summary keeps. Every request verbatim, the decisions, the work done with its paths and artifact ids, the open work with the task list, and the facts the rest depends on. A fact carries the tool result reference of the read or search that found it, so the agent can read the source back; work done carries none, because its path or id already finds it. The screen shows the summary with references taken out.

Language. The summary call quotes up to eight of your latest paragraphs and asks for the summary in the language most of them are in. Section headings stay in English; quotations, names, document codes, figures, paths, ids and references are copied without translation.

Blocks

A message is an ordered list of seven block kinds: thinking, text, tool use, tool result, clarification request, approval request and compaction. A compaction block holds the summary as its text and AUTO or MANUAL as its trigger, and sits in the assistant message where it happened. Only a text block may be terminal.

Block on screenDrawn as
Pre-tool narrationNon-terminal text, one size below the answer once the turn has one.
ThinkingSmaller still, in the faintest ink, never opened for the reader.
Live textPlayed out a character at a time about 0.6 seconds behind what has arrived, never slower than 40 characters a second. Speed eases toward its target over about 300 ms, so a sentence released by a guardrail check speeds up gradually. A tone mark or emoji is never split. Each word resolves from a blur, the caret breathes while more is coming, and what is left plays out rather than jumping in.
Settled or reloaded replyPlain text.
Compaction being writtenThe divider’s two rules draw in toward a shimmering Summarising conversation, with a clock after three seconds, in place of the thinking indicator.
CompactionA divider labelled Context summarised, marked automatic when the agent chose it, which opens to show the summary. Messages above the newest one are dimmed until hovered.
/compact sentA pill reading Compact and the instructions, in place of the typed command.

Why it works this way

Why replay tool calls as tool calls?

The model sees what it actually did, in the shape it understands, so it can reuse a result or fetch the rest by reference instead of guessing. Old results shrink to a line because every past turn is paid for on every request.

Why does compaction use the turn's own model?

The history being summarised is close to that model’s context window, and the organisation’s background model may have a smaller one. Compaction runs on a separate instance of the turn’s model, with the same prompt for both kinds, and leaves a usage row priced at the turn’s model like any other call.

Why quote your paragraphs to pick the language?

The portal stores no language for a person, and tool output and documents fill most of a transcript. Your own words are what tell the model which language you write in.

Under the hood

Compaction prompt details

The language sample leaves out runtime notes, the replayed summary’s sections, slash commands and paragraphs of fewer than three words (such as a pasted reference). When the history opens with an earlier summary, the prompt names it by the note it is replayed under and asks for everything in it to be carried into the new one.

Block invariants

Six block invariants live in domain code; the load-bearing one is that only a text block may be terminal. A turn’s context size is overwritten by each call on the turn’s own model; summary, review and compaction calls carry none.

AI Portal Docs
EN VI