Context Surgeon
Let AI agents edit their own context window
Get picks like this daily. Today's launch numbers, the top launches, AI and tech news, and a daily opportunity pick, straight to your inbox.
Want to reach these readers? Sponsor an issue.
AI agents accumulate stale tool results — file reads, web fetches, bash outputs — in their context window. Every one sits there for the entire conversation, consuming tokens and degrading quality. The standard fix is auto-compaction: wait until full, then drop content indiscriminately.Context Surgeon gives the agent three operations — evict, replace, and restore — so it can manage its own context. It works as a transparent local proxy that intercepts API requests, assigns IDs to content blocks, and applies eviction directives before forwarding. The agent calls the tools via bash. The proxy is ephemeral: starts with your CLI session, dies when it ends.The interesting part is that agents naturally start managing their own context without much prompting. In testing, the agent decided on its own to evict old research results before starting an implementation phase.Works with Codex CLI and Claude Code.Install: npm install -g context-surgeon Usage: context-surgeon codex
HN · launched Apr 13, 2026 · 5 upvotes (top 89%) · 0 views
Niche: ai agent memory infrastructure · 350 launches, 11 in the last 7 days ▼ -58% · Explore this niche →
Category and tags
- Horizontal
- Agent / copilot
- Developer
- AI-native
- Commercial product
Visit website ↗ Source listing ↗
More like this: all 350 launches in ai agent memory infrastructure →
Could you build this?
Yes Context Surgeon is an MCP server or middleware helper providing tools for agents to edit or prune previous tool call messages in their conversation history, which is straightforward prompt/message-array manipulation.
Discussion
5 comments analyzed.
Feature requests: Automatic state persistence to file between sessions, Project-level configuration folder (like .git) for storing state, Multi-session work support
Competitors
Other products that read as similar to this one : 689 launches clear the similarity bar, closest 8 shown.
Attention rank: #648 of 690 (itself plus its competitors, highest first, normalized so YC and Product Hunt are compared fairly).
Launched 161 days after the earliest competitor.
- Context-compact · hn · 2026-03-07 · 6 upvotes · similarity 0.57
- UltraContext · hn · 2026-01-21 · 21 upvotes · similarity 0.52
- I built a tool that turns any API into a CLI for agents · hn · 2026-03-01 · 6 upvotes · similarity 0.52
- ContextOS · ph · 2026-09-16 · 7 upvotes · similarity 0.49
- Context Auto-Maintainer · ph · 2026-09-29 · 2 upvotes · similarity 0.49
- Context Gateway · hn · 2026-03-13 · 97 upvotes · similarity 0.49
- A Context Registry for AI coding agents · hn · 2026-09-03 · 9 upvotes · similarity 0.49
- A better way to handoff web bugs to AI agents · hn · 2025-11-25 · 5 upvotes · similarity 0.48
The niche, labels, vibe code rating and competitor comparison on this page are analysis by Nicheloom. If you use them, please credit nicheloom.com. How you may use our data.