Skip to main content

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

Project description

Sponge 🧽

PyPI version CI Python 3.12+ License: MIT

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

sponge_ai-0.1.2.tar.gz (77.5 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.2-py3-none-any.whl (79.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sponge_ai-0.1.2.tar.gz
  • Upload date:
  • Size: 77.5 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.2.tar.gz
Algorithm Hash digest
SHA256 0edf340c9e02bb3dca17a56e42223e3839e73c055e972477c442623c52c62b73
MD5 4ca1cc0c1d2900b7a43ed5a4b25dc962
BLAKE2b-256 6a79fc271a3be4f2fc0fdffa17e0d3d808b87b52e05c972edc09416f08355fc0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sponge_ai-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 79.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d37b4bd1cabfba81343c2aadcf6cff589d8b4c3ff26235c1dbfcacfb52469560
MD5 2788c8d119e67dbd893ec91df7c4e9a6
BLAKE2b-256 440a96d71fbc8061472fa560e947178867b50dd56ef8492a128f2f3c5d62e102

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