Context budgets
One budget for what CodeBook sends a model, the same for every role, and the limit on a brief handed to an outside runtime.
Every model call CodeBook makes is held to one budget contract. It is the same for an agent at a station, a crew, a chat or card discussion, a workflow manager, the factory supervisor, the planner and the agent points of a test run.
How a call is budgeted
- The model's window. The model's context window, less room for the answer and a margin. When the window is not known, the input is held to a fixed size.
- Your cap. A factory can set a lower input cap for a role. A cap can only lower the budget. It never raises it above what the model allows.
- MadeBook's share. In a workspace linked to MadeBook, the brief MadeBook prepares takes a share of the input: 25% for station runs and crews, 20% for the other roles, unless you set another share. CodeBook does not retrieve this material. It only fits MadeBook's brief into its share and assembles the call.
- Then history. Older tool output, and then older steps, are shortened to fit what is left.
The instructions, the tool list, the card and every message a person wrote are never shortened. If those alone do not fit, the call is refused and the refusal says which limit applied. A refusal caused by a factory cap names the cap and where to raise it.
When MadeBook's brief is larger than its share, the current state, decisions and what every agent is told stay whole. Knowledge passages are kept whole or left out. The compiled package is cut last. The model is told what was left out.
Set a factory's budgets
Open Factory settings → Context budgets. The tab is shown in advanced mode.
- Model calls, by role lists each role. Leave Input cap (tokens) empty to use the model's own budget. Leave MadeBook share (%) empty to use the default share.
- Briefs for outside runtimes sets Brief limit (bytes) for the JSON brief CodeBook hands an outside runtime. Leave it empty to use the transport limit.
Only a factory owner or admin can save. Everyone who can read the factory can see the settings. Each save is recorded in the audit trail.
These settings belong to the factory. Factory versions, blueprints and factory files do not carry them.
See what a run was allowed
Open a run in the card's timeline, or expand a run in the station's run history, and choose Context budget. For each model call the dialog shows the contract that applied (the model's window, the factory cap, MadeBook's share), what was sent in each section (instructions and tools, MadeBook's brief, the card and messages, earlier steps) and what was shortened or left out, by name and size. No prompt text is stored or shown here.
The same dialog lists Briefs handed to an outside runtime for that run.
Budget records are kept for 90 days and are deleted with the factory.
Briefs for outside runtimes
Every brief handed to an outside runtime, a pulled claim or a Run here session carries a budget_contract block:
- the byte limit that applied and where it came from (the transport limit, the factory's brief limit, or the size limit of a GitHub Actions dispatch);
- what is never cut;
- the order things are cut in: oldest comments first, then oldest artifacts, each whole;
- what was cut, the bytes used and a hash of the brief.
CodeBook checks that the contract matches the brief before handing it over, and records it with the run. An outside runtime can use the block to tell whether it received the whole card.
Limits
- Token counts are CodeBook's estimates, corrected per model family from reported usage. They are not a provider's tokenizer.
- A crew fits MadeBook's brief once for all its participants, not to each participant's model.
- Budgets for chat sessions and planner work orders are recorded but have no screen yet.
See What the worker reads for what goes into a station run.