Context engineering for LLM agents

Shrink agent context.
Don’t touch the agent.

A provider-agnostic Go core that cuts the tokens every request carries — losslessly, or lossy-but-reversibly — as an HTTP proxy or an in-process plugin. Same request in, a smaller request of the exact same shape out.

Fail open, always Never worse Reversible

Run it in one line

Point any agent at the proxy — one port serves both dialects.

context-guru-proxy --preset balanced          # or --config cg.yaml

ANTHROPIC_BASE_URL=http://localhost:4000/anthropic
OPENAI_BASE_URL=http://localhost:4000/openai/v1

What it does

🛟

Fail open, always

Any component error or panic reverts that component only. The original request is always a valid fallback.

âš–ī¸

Never worse

A component that grows the request is reverted. Token cost is measured on message content, so you never pay to compact.

â†Šī¸

Reversible

Every lossy drop leaves a <<cg:HASH>> marker and stashes the original — recoverable on demand.

🔌

Three ways to run

Proxy / gateway, in-process AuthBridge plugin, or a bifrost LLMPlugin — one core, unchanged.

🧩

13 stackable components

Lossless reformatters and reversible offloaders, ordered by config. Presets for coding, MCP, and long agent sessions.

📉

Measured, not hand-wavy

Benchmarked on SWE-bench with Claude Code: real token savings, zero task-reward change.

Before → After

The summarize config on the sample 11-message transcript — same shape, far fewer tokens.

Before

11 msgs
2,667 bytes

After

4 msgs
1,298 bytes

See all three configs →

The numbers

SWE-bench · Claude Code · claude-sonnet-4-6 · 10 tasks × 13 configs.

~27%
mask mean token savings (resolved tasks)
0
tasks broken — reward preserved 6/6
<10ms
component overhead per request
93.5%
peak savings on a long session

Explore the benchmarks →