---
title: "Caveman for the agents you build"
description: "Your framework. Your keys. More work per dollar."
canonical: https://caveman.so/build
last-updated: 2026-10-14
---

# Caveman for the agents you build

Your framework. Your keys. More work per dollar.

Tool results, logs and documents shrink before the model reads them, and the
runtime keeps every original in reach. Free and open source, in TypeScript,
Python and Go. Caveman Cloud prices every run and tests the cheaper one.

## In your app

One wrapper around the call you already make. Your framework, provider, keys
and saved history stay as they are.

```sh
npm install @caveman-ai/middleware @caveman-ai/sdk
pip install 'caveman-middleware[langchain]' caveman-sdk
```

The client packages talk to a local runtime that you start separately:

```sh
npm i -g @caveman-ai/cli && CAVEMAN_MODE=compress caveman start
```

Version 1.0 (TypeScript 1.0.1, Python 1.0.0), with 8 TypeScript and 13 Python
adapters. Certified with the Vercel AI SDK, OpenAI, Anthropic, LangChain and
LiteLLM; the others (Google GenAI, Strands, Mastra, MCP, CrewAI, Pydantic AI,
LlamaIndex, Agno, AutoGen, ASGI) are experimental. Outside strict mode, any
failure sends your original request unchanged. Savings inside apps are not
measured yet.

Docs: https://docs.caveman.so/caveman/middleware

## trim-1

A 1.2 MB model that decides which lines of a context an agent needs for its
current ask, and drops the rest. It returns the context's own lines in their
original order, with a marker where lines were removed. It never rewrites a
line. 712 gradient-boosted trees, pure Go, no GPU, no network call,
deterministic. Apache-2.0.

```sh
go install github.com/caveman-ai/trim-1/cmd/trim@latest
trim --query "why does the build fail" build.log
```

Results at the default `balanced` setting (one run on 2026-10-11, frozen
holdout splits of public suites; the long-document suite uses the validation
split of a dataset whose train split is in the training data; token counts
are local `cl100k_base`, not provider billing):

| Context | Tokens cut | Evidence kept |
|---|---:|---:|
| Long documents, 8k to 32k tokens | 88.9% | 94.4% |
| Retrieved code (lines the fix edits) | 21.8% | 90.7% |
| Coding-agent tool output (what the agent used next) | 1.9% | 100% |

7.2 ms p50 for 5,000 input tokens on one CPU core. It saves little on short,
dense tool output by design; long-document retrieval is what it is for.

- Code: https://github.com/caveman-ai/trim-1
- Model card: https://huggingface.co/caveman-so/trim-1

## Also free

No account needed. The code is open source; CaveGemma's weights follow
Gemma's terms.

- **Byte-exact recovery.** Every original is stored before anything shrinks.
  The model asks for it by handle and gets the exact bytes back.
  https://docs.caveman.so/caveman/context-recovery
- **Smaller tool schemas.** `caveman-shrink` keeps tool names, parameters,
  enums and required fields, and shortens long descriptions. Shorter
  descriptions can change which tool the model picks.
  https://docs.caveman.so/caveman/local-tools
- **Smaller web pages.** A browser tool that returns the content an agent
  needs. Four tools, 297 tokens of catalog against 3,422 for Playwright MCP
  (offline o200k_base counts, inferred). Action-heavy flows can cost more.
  https://caveman.so/products/caveman-browse
- **One runtime for every service.** Run the compression runtime as a shared
  service in Docker, Kubernetes, ECS, Cloud Run or Fly.io.
  https://docs.caveman.so/caveman/deploy
- **Open weights.** CaveGemma is Gemma 4 31B tuned to answer short with no
  prompt: 27% fewer output tokens across 193 held-out pairs.
  https://caveman.so/products/cavegemma

## Caveman Cloud

Know what every run cost, and ship the cheaper one with proof. Point your SDK
at Caveman and keep your provider keys. Works with the OpenAI, Anthropic and
Vercel AI SDKs, LangChain, LiteLLM and OpenTelemetry.

- **Cost per task.** Every run priced, retries and failures included, tied to
  the workflow, customer and session behind it.
- **Evals on your traffic.** Datasets from recorded runs, graded by your
  scorers. Gate CI on the result.
- **Routing per workload.** Move one workflow to another model; backtest it on
  saved traffic first.
- **Fixes, proposed and tested.** Caveman finds the waste, proposes a change
  and tests it on recorded work. Your team approves what ships.
- **Budgets.** Soft and hard caps per project, rate limits per key and
  workflow.

Start free: https://app.caveman.so/signup
