Skip to content

Memclaw v0.2.0 — 81% cheaper with raw Anthropic API

Choose a tag to compare

@emanuilo emanuilo released this 16 Mar 08:36
· 26 commits to main since this release

Replaced the Claude Agent SDK with a direct Anthropic API integration. The SDK silently injected ~20k tokens of unused built-in tool definitions on every call — removing it drops
real-world cost from $0.13 to $0.025 per query.

Benchmark results (claude-sonnet-4-6)

Metric v0.1.1 (SDK) v0.2.0 (Raw API)
Avg cost/query $0.132 * $0.025
Avg latency 11.2s 6.2s
Input tokens/call ~20,000+ ~7,400
Cost reduction — ~81%
  • SDK costs measured from 16 production Telegram bot queries. Raw API costs from a 10-query benchmark.

What changed

  • claude-agent-sdk dependency removed — no more Claude Code subprocess spawned per session
  • Hand-rolled agentic loop — simple while-loop with tool dispatch, only our 8 tools are sent to the API
  • Token-efficient tools beta enabled via anthropic-beta header
  • Per-query cost logging — every call now logs exact input/output token counts and dollar cost
  • Tools extracted to tools.py — agent.py cut from 689 to 310 lines

No breaking changes

Same CLI commands, same Telegram bot, same ~/.memclaw/ file layout, same env vars.

Upgrading

pip install --upgrade memclaw
pip uninstall claude-agent-sdk # no longer needed