Context engineering and efficient tool calling

Keeping long-running agents fast and on-task: compressed tool results, selective tool history, token counting and context providers.

Context
Tool calling
Compression
  1. Long-running agent
    • Many tool calls
    • Large tool outputs
    • Long conversations
  2. Context engineWhat I built
    • Compress tool results
    • Keep last N tool calls
    • Count tokens
    • Context providers
  3. Model sees
    • Compact context
    • Only the tools it needs
The full history stays in the database - only what the model sees gets smaller.
Compression kicks in at a count or token threshold, whichever comes first.

Efficient tool calling

  • Tool-result compression: once outputs pile up, agents summarize them instead of re-sending raw tool output every turn.
  • Selective tool history: keep only the last few tool exchanges across runs.
  • Token counting that works across OpenAI, Anthropic, Bedrock, Gemini and LiteLLM, wired into compression.
  • Prototyped “code mode”, where an agent batches many tool calls into one generated Python step - a large cut in tokens per task.

Context providers

  • Gmail and Calendar providers with separate read and write sub-agents and minimal scopes.
  • Live streaming of sub-agent tool calls to the parent, so frontends can show what’s being looked up.
  • Hardened context providers: injectable write tools, query timeouts, and Git access that keeps tokens off disk.
Back to Work