#36

Cost accounting and cheaper code paths

Drafttobi-techywants to merge intofrom

Draft. Cuts one recorded e2e run (43 agent turns) from ₦967 as main counted it to ₦706, measured offline at ₦0 on the recorded run. Details in COST.md.

Agent costPer turnModel calls
Before, as main counted it (cached input at the full rate)₦967.48₦22.50117
Before, cached input at Meta's cached rate₦769.13₦17.89117
After (defaults)₦705.93₦16.42111

Of the ₦261.55 drop, ₦198.35 is accounting (cached input priced at $0.15 per 1M, which Meta already bills) and ₦63.20 is real spend cut by the plain-code paths.

What is in it

  • One metering seam: router, steer, binding, readers, SAM and speech to text booked to the daily naira cap and the run budget; prices in mimi/models/prices.py (MIMI_CACHED_RATE=0 restores the old accounting).
  • Plain-code paths (MIMI_PLAIN_CODE): balance, promo and quiet approvals on by default; delivery receipt and stock paths built but off until a live e2e re-record. Same tools, tiers, Go policy, approvals and claims gate; any surprise hands the step to the model.
  • prompt_cache_key per shared prefix (body only, recordings replay unchanged).
  • Shared-prefix context layout behind MIMI_CTX_SHARED_PREFIX=1, off (needs a live re-record).
  • Demo kill switch also refuses new and reset sessions.

Measure: META_API_KEY= python -m mimi.api.e2e --no-write (after) and the same with MIMI_PLAIN_CODE=0 (before). No live model calls, no deploy.

Activity

6
coderabbitai[bot]1d ago

IMPORTANT

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This pull request is a draft

Merging is unavailable until it is marked ready for review.