# Clear old tool results

> Long sessions keep every earlier tool result in context, and most of it is never read again. Context editing drops stale tool results as the conversation grows, and compaction summarises older turns. Both keep long runs inside the window without starting over.

Last checked: 30 Nov 2026, against the vendor's own pages.

Family: Return less.

## Where it fits
- **Building my own agent**: fits. Context editing and compaction on the Claude API.
- **Using a coding agent**: fits. /compact and automatic compaction.
- **Using an enterprise assistant**: partly. Handled by the vendor.
- **Using a workflow tool**: not available. Runs are short.

## The setting in each harness
- [Claude API and Agent SDK](https://usefewertokens.com/harnesses/claude-api/): context_management with clear_tool_uses_20250919, or server-side compaction ([source](https://platform.claude.com/docs/en/build-with-claude/context-editing), read 30 Nov 2026)
- [OpenAI Responses and Agents SDK](https://usefewertokens.com/harnesses/openai/): context_management: [{ type: "compaction", compact_threshold }] on Responses requests ([source](https://developers.openai.com/api/docs/guides/compaction), read 30 Nov 2026)
- [Pi](https://usefewertokens.com/harnesses/pi/): /compact, and the compaction settings for automatic compaction ([source](https://github.com/earendil-works/pi/blob/4a080252f06caf63a525d7873c5d94d3c23887e0/packages/coding-agent/docs/compaction.md), read 30 Nov 2026)
- [Claude Code](https://usefewertokens.com/harnesses/claude-code/): on by default, auto-compaction summarises old turns; CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50 makes it compact earlier ([source](https://code.claude.com/docs/en/env-vars), read 30 Nov 2026)
- [Codex](https://usefewertokens.com/harnesses/codex/): on by default, automatic compaction at the model's default threshold; model_auto_compact_token_limit moves it ([source](https://learn.chatgpt.com/docs/config-file/config-reference), read 30 Nov 2026)
- [OpenCode](https://usefewertokens.com/harnesses/opencode/): compaction: { auto: true, keep: { tokens: 15000 } } in opencode.json ([source](https://opencode.ai/docs/config/), read 30 Nov 2026)

## Read more
- [Why AI agents kill their own context windows](https://www.stackone.com/blog/agent-suicide-by-context/)
- [Effective context engineering for AI agents, from Anthropic](https://www.anthropic.com/research/effective-context-engineering-for-ai-agents)
