WukongDojo.AIAI is here, just build it
English

Docs - Context

Context and token estimation

Every agent turn stacks six layers of context. See exactly what fits in each one and how many tokens it costs.

1. The six layers

Agent context is built in order. Each layer is measured separately.

LayerWhat it holds
SystemThe agent's core identity and behavior instructions — set once when the agent is created.
ToolsTool definitions — the names and descriptions of every tool the agent can call.
InstructionsPer-turn instructions you've written into the system prompt — updated before each turn.
KnowledgeAll files you attached to the agent from your knowledge library — injected into the prompt.
HistoryAll prior messages in this conversation — grows as the user and agent exchange turns.
MessageThe user's current input — the thing the agent is about to respond to.

2. Token estimates

Every layer carries a token estimate: the number of tokens the layer will consume in the model's input. We estimate tokens as ceil(characters ÷ 4) — the same heuristic the runtime uses for budgets. Larger files, longer history, or more tools push the estimate up. You can read the exact estimate for each layer on every turn.

3. Reading a snapshot

After each turn, a snapshot of the context layers is available in the inspector. You can see the character count and token estimate for every layer, so you know exactly what went into the model that turn. This is useful for debugging why an agent isn't seeing certain information, or why a conversation is suddenly costing more tokens.