Skip to content
Cavemandocs
MIT

Optimize existing app

Keep your framework. Choose an integration and see whether Caveman applied an optimization.

Add Caveman to an application or agent you already own. Keep your framework, model provider, and tool loop. Choose the integration that matches what you want to change.

Using Claude Code or Codex rather than building an application? Start with coding-agent setup.

Choose your framework#

Check what you want to optimize#

Your situationStart withWhat changes
Tools return long logs or text to your agentFramework middlewareEligible tool-result text in the outbound request
You can change a provider base URL, but not the agent loopProxy integrationSupported traffic passes through a separately running proxy
You want to compress a specific payload yourselfSDK compressionYour code chooses what to compress and how to recover it
You need usage observations from an existing frameworkAgent SDK adaptersLifecycle hooks and normalized usage records
You are starting a new agent runtimeAgent SDKCaveman owns the agent definition and execution

What middleware does automatically#

Middleware selects eligible tool results before a provider call, asks the Caveman runtime to optimize them, and passes the accepted outbound copy to your existing provider client. When a lossy transform is supported, the native tool loop can retrieve the original. Your stored conversation stays yours.

It does not automatically route models, add memory, shorten every message, or optimize an entire project. In the Vercel integration, a chat without eligible text tool results can produce a valid answer without applying any compression. Structured object results, errors, and images are not text candidates in that adapter.

Follow one path to a working result#

The Vercel AI SDK guide includes the complete application, a small integration diff, and a local check using the real Caveman runtime with a fixture provider. Start in record mode, enable compression, and inspect the report before comparing token use.

Middleware packages are alpha. They call a separate runtime over HTTP; installing the npm package does not start that runtime. Read deployment before moving the application off your laptop.

A decision report answers whether middleware applied a transformation. It does not prove lower provider usage or a smaller bill. See how numbers are counted.