Skip to main content

Cost-optimal AI agent harness — use the best model, pay the least

Project description

Sponge 🧽

Same model. Same quality. Fraction of the tokens.

Sponge wraps your LLM calls with architecture-level cost compression — not by switching to cheaper models, not by bolt-on caching. Every layer of the agent loop is designed to minimize token consumption.


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/your/sponge.git
cd sponge
pip install -e ".[dev]"
pytest                  # 106 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

sponge_ai-0.1.1.tar.gz (77.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sponge_ai-0.1.1-py3-none-any.whl (79.1 kB view details)

Uploaded Python 3

File details

Details for the file sponge_ai-0.1.1.tar.gz.

File metadata

  • Download URL: sponge_ai-0.1.1.tar.gz
  • Upload date:
  • Size: 77.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sponge_ai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ac0330e1236d0ef0c4a7a48f5cda0a5193c345d4bbdbec39e40fd2345aecf4d1
MD5 221ec68e5cce75a971a3274f1f41c272
BLAKE2b-256 b26aebf960a76e3bd61d8fa328a1b3a56c9b5568e268e6e012f253ab080d47dc

See more details on using hashes here.

File details

Details for the file sponge_ai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sponge_ai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 79.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sponge_ai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b193090adcc4d48e01ef99cea3c304bda2e2115519e3558d052f51e4ce6fb259
MD5 63c2b544994c448ad3e25b4a0fcacb41
BLAKE2b-256 5cac840c9fbf96df052b61fb222ca2a3e009002c081ff14a78262f23210e7bbf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page