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.4.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.4-py3-none-any.whl (79.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sponge_ai-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 6ddb6a444efb8063a284dc03f40e2458e611daec4d466e1599f960e333483c67
MD5 684dfb41de5e034229591d601d592ae7
BLAKE2b-256 0b609b6368fe91e5c4296544fe9bd91adcc4af2282ee902ba40329676e086722

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sponge_ai-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 afae4cabf8db9a9857364970db334e34ada5c3dcc6ea444e106a0056482d2ae0
MD5 063a98fb96f1522573b4c4aa28bd5ba0
BLAKE2b-256 cd23f2eda30b4d8ed44fb01fd2c17a10f6073e4cb87b3adfbabedd510111528b

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