Skip to main content
Every agent turn ends in one model request. The request holds a system prompt, the conversation history, and the tool list. This page explains which values the model sees each turn, where they come from, and how to keep a value out of the prompt. To learn how the platform keeps the request small, see Context size, compaction, and budgets.

At a glance

The platform shapes each source of context before the model reads it:
  • Memory and ## Current Context: visibility rules and size limits.
  • Conversation history and tool results: compaction.
  • Knowledge-base results: a token budget.
Guardrails check content at set points: user input, the agent’s reply, tool input, tool output, and handoff. A tool-output guardrail runs before the result enters the model context.

What the model sees each turn

Session values reach the system prompt in two ways:
  • Through the memory sections an agent declares, such as ## Session Memory and ## Granted Memory.
  • Through a ## Current Context block.
The agent’s visibility mode decides which values go into ## Current Context. In both modes, these values never appear in ## Current Context:
  • Platform identifiers (session, tenant, project, and user IDs), raw input, and message metadata.
  • The config, env, session, and intent namespaces.
  • Keys that start with last_search_kb_, last_browse_kb_, or profile:.
  • Keys that start with an underscore, except the handoff summary.
  • Knowledge-base search results. They reach the model through the search tool call. See Knowledge base retrieval.
Two more rules depend on the mode:
  • Allow-list mode: a value already shown in a memory section does not repeat in ## Current Context.
  • Explicit mode: a declared session value can appear in both a memory section and ## Current Context. Plan for this when you size prompts.
Tool results are visible only to the agent that produced them. A last_<tool>_result value appears in the prompt of the agent that called the tool. See Store result. After a handoff, the receiving agent does not see the value unless you list it in pass or reference it directly. When PII protection is on for the project, the platform redacts protected values in ## Current Context before the model reads them. The raw values stay available to tools.

Size limits

What happens when a limit is reached:
  • A value is too large: the platform replaces it with a marker object that holds a preview of its start.
  • The block is too large: the platform leaves out the remaining values and lists their names.
  • A tool result is cut: the prompt adds a ## Prior Tool Result Context note. The note tells the model to call a read or search tool again if it needs the missing details. It must not repeat a tool that changes data unless the user asks again.
Keep declared memory small, because nothing limits it. You can change the limits for a project or an agent. Voice agents use lower defaults. For all default budgets and for steps to diagnose a bloated or cut prompt in a trace, see Context size, compaction, and budgets.

Keeping a value out of the prompt

Choose the option that fits the value:
  • A session or persistent memory value: set MODEL_VISIBLE: false on the entry. The model no longer sees it in automatic context, but expressions, conditions, and tools can still read it.
  • A value no agent needs to declare: do not declare it in MEMORY: and do not reference it. An allow-list agent never sees an undeclared value that it does not reference.
  • A value a tool needs: declare it as a runtime-supplied parameter that the model cannot see.
  • A tool result: use the tool’s MODEL_CONTEXT to pass the model only the fields it needs. See MODEL_CONTEXT on a tool result.
This example hides one memory value and passes a hidden parameter to a tool:
MODEL_VISIBLE: false controls automatic placement only. The value can still reach the model through an explicit reference such as {{risk_score}} in GOAL, through a tool result, or through conversation history. It also does not carry across a handoff: the receiving agent must declare its own MODEL_VISIBLE: false. For the full rules, see Model-visible session and persistent values.

Referencing values in prompt text

Use {{customer_tier}} in GOAL, PERSONA, LIMITATIONS, or SYSTEM_PROMPT:. The platform fills in the value and, in allow-list mode, admits it to ## Current Context. The form {{context.customer_tier}} works the same way. Use the shorter form. If a referenced value is not set, the literal {{customer_tier}} text stays in the prompt. Write the sentence so it still reads well with an empty value, or set a default with INITIAL:.
The platform leaves {{config.*}} and {{env.*}} values out of ## Current Context. This protection does not apply to a {{env.KEY}} reference that you write directly in GOAL, PERSONA, LIMITATIONS, SYSTEM_PROMPT:, or RESPOND. The platform sends the resolved value as plain prompt text. Referencing environment variables in those fields is supported. Use it only for a variable that is not marked Secret. The Secret flag only masks the value in the Studio UI. A secret variable in a model-visible or customer-visible field is not protected.

Related articles: