Study FAQ
How can I reduce the context used by Claude tools and tool results?
Also asked as 2
- When should I use tool search, programmatic tool calling, or context editing with Claude?
- What can I clear from Claude tool history, and does prompt caching free context space?
Answer
Choose the technique that addresses the source of context pressure. On a supported Claude API model and deployment, use tool search to defer rarely needed tool definitions, programmatic tool calling to keep suitable intermediate results out of the model’s conversation, and context editing to clear obsolete history. Prompt caching can reduce the cost of repeated prefixes on a cache hit. Cached tokens still occupy the window.
- Defer tool definitions when only a few tools are needed per turn. Discovery adds a lookup, so keep essential tools immediately available.
- Use programmatic tool calling for compatible tool chains in which code execution can aggregate or filter results and return a compact result to the model. Tools marked
strict: truerequire a different approach because they cannot be called programmatically. - Use the
context-management-2025-06-27beta and selectclear_tool_uses_20250919for stale tool results orclear_thinking_20251015for older thinking blocks. Confirm that the strategy is supported with the model, deployment, and other features you use.
Before clearing a result, extract the resource ID, version or timestamp, validation outcome, and a concise evidence summary. Keep protected external records of privileged actions and safety-relevant failures. Define when the workflow should re-fetch original evidence or use a smaller tool set if a context feature is unavailable.
Managing tool context · Claude API context editing · Programmatic tool calling constraints
Full explanation
Context Windows, Compaction, and Tool-Context Control
Study guide · CCAR-F
Read the full explanation