Cost-optimal AI agent harness — use the best model, pay the least
Project description
Sponge 🧽
Same model. Same quality. 1/10 the tokens.
Sponge is an architecture-level cost compression harness for LLM agents. It doesn't switch you to cheaper models or bolt on caching as an afterthought. Every layer — task decomposition, context loading, sub-agent results, memory — is designed from first principles to slash token consumption. Same model quality, dramatically lower cost.
Quick Start
pip install sponge-ai[deepseek] # or [anthropic] or [openai] or [openrouter]
export SPONGE_DEEPSEEK_API_KEY=sk-... # or SPONGE_ANTHROPIC_API_KEY etc.
sponge run "explain the CAP theorem in one sentence"
How It Saves Tokens
| Layer | What It Does | Cost |
|---|---|---|
| Plugin Routing | File ops, code search, shell commands → handled locally | $0 |
| Exact Cache | Identical tasks return cached result (SHA256 match) | $0 |
| Semantic Cache | Similar tasks match via Jaccard similarity | $0 |
| Self-Tuning | Detects waste (TTL too short, budget too loose) → proposes fixes | 5-20% |
| Context Compression | Old conversation turns summarized, not re-sent | 2-5× |
| Task Decomposition | Complex tasks split into focused sub-tasks | 5-10× |
| LLM Call | Only when nothing else works | Full price |
Commands
sponge run "task" # Execute a task
--model, -m MODEL # Override the model
--json # JSON output
--auto-approve # Allow write/delete/shell operations
sponge benchmark # Run benchmark fixtures against a real provider
--fixture, -f NAME # Run a single fixture
--output, -o FILE.json # Save results
sponge cost session # Cost breakdown for latest session
sponge cost total --days 30 # Total cost over N days
sponge cost stats # Overall efficiency statistics
sponge tune report # Detect optimization opportunities
sponge tune apply ID # Activate a tuning proposal
sponge tune review # Evaluate active experiments
sponge session start # Start a multi-turn conversation
sponge session chat "msg" # Send a message
sponge session resume ID # Resume a saved session
sponge session list # List all sessions
sponge memory add "rule" # Add project convention
sponge memory list # List all conventions
sponge memory remove N # Remove a convention
sponge config show # Show current configuration
sponge config set KEY=VAL # Change a setting
sponge --version # Show version
Supported Providers
| Provider | Install | Env Var |
|---|---|---|
| Anthropic (Claude) | [anthropic] |
SPONGE_ANTHROPIC_API_KEY |
| OpenAI (GPT-4o) | [openai] |
SPONGE_OPENAI_API_KEY |
| DeepSeek (V4) | [deepseek] |
SPONGE_DEEPSEEK_API_KEY |
| OpenRouter (200+ models) | [openrouter] |
SPONGE_OPENROUTER_API_KEY |
Switch via SPONGE_PROVIDER env var or sponge config set provider=deepseek.
Project Memory
Create .sponge/memory.toml in your project root (or use sponge memory add):
[memory]
rules = [
"Never modify tests/fixtures/ without asking",
"Use httpx instead of requests",
]
These are injected into every LLM call as system instructions.
Cost Transparency
Every LLM call is logged to ~/.sponge/telemetry/fingerprints.db:
sponge cost stats
# Sponge Efficiency Stats
# Total calls: 42
# Cache hits: 23 (55%)
# Plugin calls: 8 ($0)
# LLM calls: 11
# Total cost: $0.002347
# Naive cost: $0.005120
# Total saved: $0.002773 (54.2%)
Development
git clone https://github.com/ihgoa501-stack/sponge.git
cd sponge
pip install -e ".[dev]"
pytest # 157 tests, zero API calls required
ruff check src/ # lint
mypy src/sponge/ # type check
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sponge_ai-0.2.0.tar.gz.
File metadata
- Download URL: sponge_ai-0.2.0.tar.gz
- Upload date:
- Size: 91.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac4b4028bb109d7250b8ec25d1bef05e236f564ac0d984e7657209470b95e635
|
|
| MD5 |
b3d9d3b54393b7f15b49024536e0a13b
|
|
| BLAKE2b-256 |
8ab8a05a1b783437fa2e51ab1f8858bdf59efcc7c25b5b45ae61f8537dc49d08
|
File details
Details for the file sponge_ai-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sponge_ai-0.2.0-py3-none-any.whl
- Upload date:
- Size: 91.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
984efc211e72a128ae3695f78555d50de03a28e27513835383e085bf1544ba0e
|
|
| MD5 |
0105c76ea513c492d5213b454fb8e318
|
|
| BLAKE2b-256 |
f49c73f082ce371633e2a1a36caf60995f3f2da79bc3b90c5db79d56b807b655
|