Carolopedia

A friendly guide to Carol, her ecosystem, and the agents who built her.

📖 CarolopediaServicesBuild InitiativesAll activitiesINI-999900624Guide page
📋

CAROL-INI-2318-02: LLM cost accounting: record tokens per execution, per-model rate card, compute DeepSeek costs, fix the Carol Cost Tracker

Initiative
Open in Initiatives →

📖About

Ninad direct order 2026-07-03, four connected gaps: (1) TOKENS NOT RECORDED - the bypass metrics writer hardcodes tokens=0 and its upsert never updates the tokens column, so the Activity Tracker listing always shows 0 tokens; fix: sum input+output tokens from the executions droid runs and update on conflict. (2) NO PER-MODEL COST - the DeepSeek provider records token usage but never computes cost_usd (9767 runs since Jul 1: ZERO have cost) while Claude CLI self-reports; fix: new shared rate-card module (per-model input/output/cache-hit rates per 1M tokens) used by the DeepSeek provider to compute cost per call, honoring cache-hit pricing. (3) RATE CARD - the same shared module renders as a rate-card table in the Carol Cost Monitor app (models x input/output/cache prices), one source of truth for display and computation. (4) COST TRACKER BROKEN - every data endpoint 500s because a helper function named _idb shadows the initiatives-db module import of the same name (broken INI-2038 relay-migration edit); fix the shadowing.

⚖️Decisions

  • Follow-on to parent INI 999900618 (orion)
  • Scope inherited verbatim from parent INI 999900618 per CAROL-INI-361. (elrond.initiative_author)
  • Orion remediated: INI-999900696 bypass closed — CAROL-INI-696 close-marker: the Orion bypass INI-999900696 filed against this parent reached terminal state (closed). This row's literal prefix Orion remediated: is the canonical signal the cookbook-155 dispatcher gate looks for. (shared.bypass.bypass_end)
  • Filing mode changed planner -> bypass — Ninad order 2026-07-04: implement LLM cost attribution via bypass; dedup gate routed the work here (CLI-023). (orion)
  • CLI-023 (Ninad 2026-07-04): scope of this follow-on narrowed to LLM cost ATTRIBUTION - the shared LLM caller gains an ambient attribution context and writes initiative_id + agent_id into every cost-log entry; Elrond's reviewer and the bypass close path set it; the bypass metrics rollup adds the initiative's cost-log tokens. The dedup gate routed the CAROL-INI-2341 filing attempt here (same family). Pre-create filing-gate calls have no initiative yet and stay day-bucketed by design. (orion)
  • [status-router] planned -> executing | event=bypass_executing | bypass transition (or-bx-01)
  • [status-router] executing -> reviewing | event=bypass_reviewing | bypass transition (or-bx-01)
  • [status-router] reviewing -> executing | event=operator_signoff | CLI-023 extension: first close ran before the code patches landed (filing-order slip, caught by the dogfood check); patches are now on disk — this session's close is the live verification. (orion)
  • [status-router] executing -> reviewing | event=bypass_reviewing | bypass transition (or-bx-01)
  • [status-router] reviewing -> executing | event=operator_signoff | CLI-023 extension 2 (Ninad: tokens still 0 for most initiatives): the pipeline's run tokens were never rolled up to initiatives - the metrics store only refreshed at bypass close. Adding a live rollup. (orion)
  • Handover-watchdog: planner-pending nudge for phase 3 (auto-invoked Elrond planner). (elrond)
  • Handover-watchdog: planner-pending nudge for phase 3 (auto-invoked Elrond planner). (elrond)
  • [status-router] executing -> reviewing | event=bypass_reviewing | bypass transition (or-bx-01)
  • Orion remediated: INI-999900842 bypass closed — CAROL-INI-696 close-marker: the Orion bypass INI-999900842 filed against this parent reached terminal state (closed). This row's literal prefix Orion remediated: is the canonical signal the cookbook-155 dispatcher gate looks for. (shared.bypass.bypass_end)
  • [status-router] reviewing -> closed | event=operator_signoff | Auto-accepted (CAROL-INI-1859): Orion-initiated, >2 days in reviewing with no objection. (el-srac-01)

Success criteria

  • Bypass metrics writer records real token sums per initiative (tokens column updated on conflict); new bypass closes show tokens in the Activity Tracker listing (must_have)
  • DeepSeek calls record computed cost_usd from the shared rate card (cache-hit pricing honored), verified with a live call or unit computation (must_have)
  • Carol Cost Monitor endpoints return data (shadowing bug fixed) and the UI shows the model rate-card table (must_have)
  • An initiative's token count includes the LLM calls it caused (twin review, Palantir narration, Elrond's review) - a bypass initiative no longer reads 0 tokens after close (verified live on this initiative's own close) (must_have)
  • Every new cost-log entry carries the initiative it was spent on plus the calling agent, so Ninad sees per-initiative LLM spend instead of anonymous day totals (must_have)
  • Existing displays keep working - day totals keep their shape and entries without an initiative still land in the day bucket (must_have)
  • Initiatives whose pipeline runs consumed tokens show those tokens in the Activity Tracker WITHOUT waiting for any close-time writer - 842 token-bearing runs now surface on their initiatives (verified live) (must_have)