Overview
Build the model’s input from named sections with visible budgets and contents.
sys.time · identity · tenancy · rulesprompt · skill.0 … skill.ntool.<id> · allowed descriptionsrender.<block> · reader outputhistory · current user brief{ id: "render.profile",
text: "User prefers concise answers.",
budgetTokens: 128, usedTokens: 8 }Context is the information supplied to an agent's model for a turn. Keel assembles it from named sections: the current time, the app's ambient sections, framework rules, instructions, tools, state views, history, and the current request.
State is what the application remembers. Context is the view of that information, plus instructions and conversation, that the model receives. A model step cannot use a stored value merely because it exists in a block.
Why use sections?
With a single concatenated prompt, it can be difficult to tell which source made a request too large or exposed an unintended detail. Named sections make that input inspectable. Each records its text, budget, and estimated size, so you can trace the input back to its source.
prompt + data
+ history + …one large string
which source grew?"prompt"
"render.profile"
"history"text + budget + usage
→ opening fit checkThe opening fit check applies two conditions: the assembled estimate plus the output reserve must fit the chain's declared window, and the assembled estimate alone must fit the declared input allocation. It refuses an oversized opening request before any model call. It is not exact provider tokenization; each later request is re-estimated as the transcript grows.
Rules by design
Known assembly order
The runtime assembles system information, instructions, tools, state views, history, and the request.
system → prompt → skills → tools → state → conversationExplicit state views
Read declarations select named readers and their budgets; stored objects are not automatically model input.
block → reader → text "render.profile"Access-filtered tools
Tool access is checked during assembly and checked again at execution.
allowed → expose tool barred → omit + refuse callsVisible size overruns
State renders can be clipped with a notice. Other section overruns produce warnings without clipping.
render too large → clip + warn prompt too large → warnFit before every request
The estimated input plus output reserve must fit the chain window, including growing tool results and recovery text.
context + reserve ≤ window otherwise → fit-overflow
Work with context
| Guide | What you'll learn |
|---|---|
| Assembling context | Follow the section order and configure instructions and skills. |
| State and tool views | Render state deliberately and filter available tools. |
| History and transcripts | Separate previous messages from work happening inside the current turn. |
| Budgets and fit | Declare allocations and understand clipping, warnings, and per-request fit checks. |
Next: Assembling context.
