DEV Community

Cover image for Built a proxy, so my AI coding sessions stop forgetting everything after 20 turns
Shweta Mishra
Shweta Mishra

Posted on

Built a proxy, so my AI coding sessions stop forgetting everything after 20 turns

If you've used Claude or GPT for a long coding session, you know the drill. Context fills up, it summarizes, and a few turns later it's suggesting a library you already rejected, or forgetting why you picked postgres over MySQL in the first place.

I built TokenMizer to fix that. It's a local proxy that sits between your app and whatever LLM you're using. Instead of dumping raw conversation history back at the model, it builds a small graph of what actually happened in the session, tasks, decisions with the reasoning behind them, files touched, errors hit.

Using it is a one line change:

from openai import OpenAI

client = OpenAI(api_key="your-key", base_url="http://localhost:8000/v1")

response = client.chat.completions.create(
    model="claude-sonnet-4-6",
    messages=[{"role": "user", "content": "Let's build an auth service"}],
    extra_body={"session_id": "my-project"},
)
Enter fullscreen mode Exit fullscreen mode

When context hits around 85%, it auto-checkpoints. I ran a 40-turn session that resumed the next day in 233 tokens instead of re-explaining the whole project from scratch. Decisions carry state too, active, superseded, invalidated, archived, so "why did we switch from React to Next.js" is still answerable weeks later instead of buried in a chat log nobody's scrolling back through.

There's also a file intelligence layer. Drop in a CSV, PDF, or Excel file, and it gives the model a schema and sample instead of burning your entire token budget on raw rows, 99%+ savings on large files.

Works with Claude, GPT, Gemini, Grok, DeepSeek, and Ollama out of the box. There's a Claude Code plugin and an MCP server if you want it wired straight into your editor.

pip install "tokenmizer[anthropic,cache]"
tokenmizer serve
Enter fullscreen mode Exit fullscreen mode

Repo's here: https://github.com/Shweta-Mishra-ai/tokenmizer

Still actively building this, would love to know if this is a problem you've hit too, and how you're dealing with it right now.

Top comments (0)