Skip to content

feat(provider-kiro): Usage shows Kiro credits - #27023

Closed
pedrocostadev wants to merge 2 commits into
pingdotgg:v2/kiro-acpfrom
pedrocostadev:kiro-usage
Closed

pedrocostadev wants to merge 2 commits into
pingdotgg:v2/kiro-acpfrom
pedrocostadev:kiro-usage

Conversation

@pedrocostadev

Copy link
Copy Markdown

Problem

Kiro turns don't appear in Usage. Kiro's local history has no token counts, only the credits it billed per turn, and Usage records require token totals with a USD-only cost.

Change

  • Contract: kiro in UsageProviderKind, and an optional credits on UsageRecord and UsageBucket. No contract version bump: older clients skip the unknown provider.
  • Reader: packages/provider-kiro/src/server/usage.ts reads ~/.kiro/sessions/*/sess_*/messages.jsonl (V3 engine, which T3 runs).
    • Each usage_summary becomes one record with its credits and no tokens.
    • The model comes from the latest "The current model is …" agent_note. session.json keeps only the last model, so it would misattribute turns after a switch.
    • The session id comes from the directory name, and turns dedupe by executionId.
  • Transcript reader: state.initial now receives the file path, so the session id can come from the directory.
  • Pricing: credit-only records stay unpriced even when the model has a known rate, so they never show as $0.
  • Aggregation and cache: credits are summed into buckets and persisted in the scan cache. No cache version bump: older servers skip kiro entries.
  • Web and mobile: the Kiro provider row and the model table show credits.
  • Docs: docs/user/usage.md.

Kiro's credits stay out of token totals, cost estimates and the daily chart. The legacy ~/.kiro/sessions/cli/ sessions aren't read.

Scope and approval

Stacked on #14693 (v2/kiro-acp). Gap reported in #14693 (comment), with open design questions there:

  1. credits field vs a generic { unit, amount }.
  2. A credits mode for the daily chart.
  3. Reading legacy cli/ sessions.

Draft until those are answered.

Verification

  • Tests added:
    • usageTranscriptStreaming.test.ts: Kiro credits follow a mid-session model switch after large content.
    • usageScanCache.test.ts: a Kiro record round-trips through the cache with its credits.
    • usagePricing.test.ts: credits at a known rate stay unpriced.
    • usageAggregation.test.ts: credits are summed, and the bucket stays unpriced.
  • Real history (Kiro CLI 2.33.0, macOS): ran the reader and aggregator over my ~/.kiro/sessions. 32 billed turns and 7.13 credits, split across claude-opus-5.5, claude-haiku-4.5 and claude-sonnet-4.5. This matches a direct jq sum over the same files.
  • Checks: typecheck passes for contracts, shared, provider-core, provider-kiro, server, web and mobile. Lint, format and knip pass.
  • Not checked yet:
    • No web or mobile screenshots yet. I'll add them before marking this ready.
    • UsageService.test.ts fails locally on 3 tests:
      • Two also fail on the base branch, because macOS reports temp folders under /private.
      • "reads configured and disabled accounts once…" fails because the test doesn't fake the home directory, so it reads a real ~/.kiro on the machine. CI has no ~/.kiro.

Done with Claude Opus 5.5 in Claude Code (T3 Code).

🤖 Generated with Claude Code

Kiro history has no token counts, only credits per turn. Adds kiro to
Usage with an optional credits field on records and buckets, a
transcript reader over ~/.kiro/sessions that follows model-switch
notes, and credits display on web and mobile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Oct 29, 2026
@t3-code-bot

t3-code-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

closing at @StiensWout's request under Provide evidence for the changed behavior.

Adds Kiro credits to the web/mobile Usage provider row and model breakdown. The author explicitly promises screenshots before marking the draft ready, but the policy applies equally to drafts and no web/mobile before/after images are attached.

submission evidence: "No web or mobile screenshots yet. I'll add them before marking this ready."

Attach clear before/after screenshots showing Kiro credits in the affected web and mobile Usage views.

thanks for trying to help improve t3 code. if you think this closure was a mistake, please open a fresh pr addressing the requirement above, and link back to this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant