# How do I set a context budget for a long-running Claude workflow?

Exam: CCAR-F — Claude Certified Architect - Foundations (CCAR-F)
Knowledge domain: Context Management & Reliability
Updated: 2026-11-25T09:22:58.195345+00:00
HTML: https://learningpathx.com/faq/CCAR-F/ccarf-claude-context-budget.html

## Also asked as

- What uses up Claude’s context window, and how much room should I leave for the next turn?
- How can I detect and handle Claude context pressure before reaching the model limit?

Set a context budget below the documented limit of the selected Claude model. Count the prompt, history, tool definitions, and available tool results in the input estimate. Reserve room for the response, likely next tool results, and any state handoff. Check the model’s output limit separately and use the API’s token-counting endpoint before sending a request near the budget.

Track input and output tokens, tool-result volume, and compaction events by session. Calibrate the operating threshold on representative work. A conversation can lose focus before it reaches the hard limit if current evidence competes with stale, verbose records.

When the threshold is reached, retrieve a smaller evidence set, summarize older context with source references, persist a handoff, or ask the operator to narrow the task. Carry forward the current policy, authorization context, decision state, and unresolved issues. For the first-party Messages API, an input that already exceeds the context window is rejected. Plan recovery before the request reaches that point.

[Claude context windows and overflow behavior](https://platform.claude.com/docs/en/build-with-claude/context-windows) · [Claude API token counting](https://platform.claude.com/docs/en/build-with-claude/token-counting)

Source: [Context Windows, Compaction, and Tool-Context Control](https://learningpathx.com/news/context-windows-compaction-and-tool-context-control.html)
