v0.0.30 — Cost Tracking for All 6 Agents
Per-Run Cost Tracking — All 6 Agents (#35)
Extends per-run spend tracking (shipped in v0.0.29 for Claude + Codex) to all 6 agents: Gemini, Qwen, Kimi, and OpenCode. Every agent now has full getSessionCost() and getRunCost() support in gateway mode.
const e = new Evolve().withAgent({ type: "gemini" }); // or qwen, kimi, opencode
const r1 = await e.run({ prompt: "Analyze this" });
const r2 = await e.run({ prompt: "Summarize results" });
const session = await e.getSessionCost();
console.log(session.totalCost); // total across all runs
for (const run of session.runs) {
console.log(`#${run.index}: $${run.cost} | ${run.model}`);
}5 Header Injection Paths
Each CLI reads custom HTTP headers differently. The SDK handles all of them transparently:
| Agent | Mechanism | Details |
|---|---|---|
| Claude | ANTHROPIC_CUSTOM_HEADERS env var |
Newline-separated, tag append |
| Gemini | GEMINI_CLI_CUSTOM_HEADERS env var |
Comma-separated, tag overwrite (avoids parser ambiguity) |
| Codex | env_http_headers in TOML config |
Per-env-var mapping |
| Qwen | settings.json customHeaders |
JSON dot-path merge, preserves MCP config |
| Kimi | --config-file with custom_headers |
Dedicated Evolve-owned TOML config |
| OpenCode | OPENCODE_CONFIG_CONTENT env var |
Deep-merged inline JSON config |
User Config Preservation
All paths preserve user-supplied configuration:
- Claude/Gemini: merge with existing custom headers from secrets
- Qwen: merge into existing
settings.json(MCP servers, other settings preserved) - Kimi: separate config file (
~/.kimi/evolve-config.toml) — never touches user's default config - OpenCode: deep-merges with user-provided
OPENCODE_CONFIG_CONTENT(custom providers, plugins, theme, model headers all preserved)
Test Coverage
- 126 unit tests covering all 6 agents' spend tracking paths
- E2E integration: all 6 agents × 2 runs each,
totalCost === sum(runs)verified - Round-trip test through Gemini CLI's actual header parser regex
Install
npm install @evolvingmachines/sdk@0.0.30 # TypeScript
pip install evolve-sdk==0.0.30 # Python