AI article

Budgeting the Claude Context Window Before It Truncates You

Community description: The Claude context window is one token budget shared by prompt, tools, thinking, and reply. I count tokens and guard it in code so a reply never truncates.

Dev.to | Sep 13, 2026 | Yaseen Khatib

Automated excerpt

A Claude model is a single fixed token budget: system prompt, tools, transcript, extended thinking, and the reply all compete for the same context window. Input and output are separate budgets — the context window caps what the model reads; a much smaller max-output limit caps what it writes per turn, and output is the resource that truncates first. Extended mode lifts the window to 1M. // Price the request before spending a single output token. const { input_tokens } = await anthropic. messages. countTokens({ `> ${CONTEXT_WINDOW}.

Selected automatically from source text; not independently written or fact-checked. Read the original for full context.

Read the original article

More AI news