LeanCTX aims to cut AI agent token waste from large tool outputs

LeanCTX helps avoid wasting tokens when they read too much information at once. Its earlier work focused on choosing and shrinking file content, but the latest update targets a different source of waste: large results returned by external tools. When a tool sends raw data straight to a model, it can quickly use up the and make the agent reason less clearly.

LeanCTX now sits between tools and the model as a gateway. Extra tools can be connected with a command such as `lean-ctx addon add repomix`, and tools that support MCP can also fit into this setup. LeanCTX treats addon output as unsafe input, removes secrets, and compresses the result to stay within a chosen .

If the result is too large, LeanCTX saves the full content to disk and gives the model a small handle instead. The saved content is indexed in the so the agent can search it later, and the registry currently includes 19 tools.

Key points

  • LeanCTX manages context and tool output for .
  • The update focuses on large external tool results that can waste tokens.
  • Tool output is cleaned for secrets and to fit a .
  • Very large results are saved to disk, while the model receives a small handle.
  • Saved results are indexed so the agent can search them later.
Read original