Commit graph

5 commits

Author SHA1 Message Date
Danny Avila
a5f9ae3351 🩹 fix: Move Token-Config Resolution to TS; Key Live Usage by Created Convo
- extract the token-config resolution (override gathering + cache lookup +
  buildTokenConfigMap) into resolveTokenConfigMap in packages/api, leaving
  the /api controller a thin request-scoped wrapper (CLAUDE.md TS rule)
- getConvoKey prefers the user message's real conversationId once the
  `created` event stamps it, so a new chat's first-response live gauge and
  totals land under the id TokenUsage subscribes to instead of NEW_CONVO
2026-06-13 13:52:30 -04:00
Danny Avila
f513665ec5 🩹 fix: Address Usage Review Findings — Cost Timing, Scoped Caches, Finalized Output
- carry the post-snapshot output estimate into the context snapshot at
  finalize so the gauge keeps the last response after live resets
- accumulate per-rate billable units and price the session cost at
  render, so usage events arriving before the token-config load still
  count once it resolves
- pass user-scoped token-config cache keys through loadConfigModels
  fetches and drop the controller's unscoped fallback to prevent serving
  another user's resolved config
- tag emitted usage events with a per-run seq so resume dedupe never
  drops a distinct call with an identical payload
- admit the static tokenConfig override in the custom endpoint schema so
  it survives zod parsing into req.config
2026-06-11 15:36:21 -04:00
Danny Avila
84436aa688 🩹 fix: Scoped Token-Config Fallback and Sequential Visibility for Usage Events 2026-06-11 14:17:17 -04:00
Danny Avila
e5ab7cf1b1 🩹 fix: Resolve Codex Findings for Context Usage Tracking 2026-06-10 23:43:24 -04:00
Danny Avila
2c7f5c38af 📊 feat: Real-Time Context Window & Token Usage Tracking 2026-06-10 23:26:23 -04:00