Context Window Budget Planning
Description
Plan token budgets across system prompt, retrieved context, tool outputs, and working state so a conversation stays within its window. The procedure is constrained by explicit inputs and acceptance criteria rather than best-effort judgment alone.
When to Use
- A task requires context window budget planning before downstream steps can proceed safely.
- Ambiguity or missing evidence would change the outcome.
- The result must be recorded with reasons and evidence for later verification.
Inputs / Outputs
| Area |
Contract |
| Inputs |
Task context, candidate inputs, and explicit acceptance criteria for context window budget planning. |
| Outputs |
A decision or artifact with recorded reasons, rejected alternatives, and verification evidence. |
| Safety |
Failures must fail closed and be reported with evidence rather than retried silently. |
Procedure
- Define the goal, the constraints, and the boundary of what this procedure may change.
- Inventory the available inputs and flag gaps or ambiguities that block progress.
- Execute the context window budget planning steps in a bounded, checkpointed way.
- Compare the actual outcome against the expected outcome and record deviations.
- On failure, apply the declared fallback path, and never widen permissions to recover.
- Emit a structured result with evidence and provenance for downstream consumers.
Runnable Example
def fits(system, tools, history, limit):
return system + tools + history <= limit
assert fits(100, 200, 300, 600) is True
assert fits(100, 200, 400, 600) is False
Failure Modes
- Acting outside the declared task boundary.
- Assuming an estimate or preview equals the verified effect.
- Retrying without preserving state or evidence.
- Using stale inputs as if they were current.
- Reporting success without checking the resulting state.
Boundary
This skill operates inside the declared task boundary. It does not grant permissions, bypass approval gates, or widen access to achieve its result.
Evidence
Context engineering is named a core 2026 agent-building skill in practitioner trend surveys. These are dated public signals, not adoption metrics.
Related
- long-context-curation.md
- context-compaction.md
- memory-indexing.md
1---2name: context-window-budget-planning3description: Plan token budgets across system prompt, retrieved context, tool outputs, and working state so a conversation stays within its window.4metadata:5 source: https://skillmd.com/skills/samotech/context-window-budget-planning6 upstream: skills/03-memory/context-window-budget-planning.md7 category: 03-memory8 version: "v1"9---1011# Context Window Budget Planning1213## Description14Plan token budgets across system prompt, retrieved context, tool outputs, and working state so a conversation stays within its window. The procedure is constrained by explicit inputs and acceptance criteria rather than best-effort judgment alone.1516## When to Use17- A task requires context window budget planning before downstream steps can proceed safely.18- Ambiguity or missing evidence would change the outcome.19- The result must be recorded with reasons and evidence for later verification.2021## Inputs / Outputs22| Area | Contract |23|---|---|24| Inputs | Task context, candidate inputs, and explicit acceptance criteria for context window budget planning. |25| Outputs | A decision or artifact with recorded reasons, rejected alternatives, and verification evidence. |26| Safety | Failures must fail closed and be reported with evidence rather than retried silently. |2728## Procedure291. Define the goal, the constraints, and the boundary of what this procedure may change.302. Inventory the available inputs and flag gaps or ambiguities that block progress.313. Execute the context window budget planning steps in a bounded, checkpointed way.324. Compare the actual outcome against the expected outcome and record deviations.335. On failure, apply the declared fallback path, and never widen permissions to recover.346. Emit a structured result with evidence and provenance for downstream consumers.3536## Runnable Example37```python38def fits(system, tools, history, limit):39 return system + tools + history <= limit40assert fits(100, 200, 300, 600) is True41assert fits(100, 200, 400, 600) is False42```4344## Failure Modes45- Acting outside the declared task boundary.46- Assuming an estimate or preview equals the verified effect.47- Retrying without preserving state or evidence.48- Using stale inputs as if they were current.49- Reporting success without checking the resulting state.5051## Boundary52This skill operates inside the declared task boundary. It does not grant permissions, bypass approval gates, or widen access to achieve its result.5354## Evidence55Context engineering is named a core 2026 agent-building skill in practitioner trend surveys. These are dated public signals, not adoption metrics.5657## Related58- long-context-curation.md59- context-compaction.md60- memory-indexing.md