Skip to content

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

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

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

Conversation

@pedrocostadev

@pedrocostadev pedrocostadev commented Oct 30, 2026 •

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

Proposal and open design questions: #27621. No maintainer approval yet. This stays a draft until it lands.

Stacked on #14693 (v2/kiro-acp). Gap first reported in #14693 (comment). Replaces #27023, which was closed for missing screenshots.

Screenshots

Same real history, Usage → Cost → 30 days. Before is ea359d5 (v2/kiro-acp), after is this branch. Isolated dev server (--home-dir /tmp/...), iPhone 17 Pro simulator (iOS 26.2).

Web

Before After
web-before web-after

After: a Kiro provider row shows "7.13 credits · Billed in credits · no token data", and the three Kiro models show credits in the Cost column. The dollar total and the chart are unchanged.

Mobile

Before After: providers After: models
mobile-before mobile-after mobile-after-models

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.
  • Known failures:
    • UsageService.test.ts: two tests fail locally on macOS and also fail on the base branch, because macOS reports temp folders under /private. The accounts test now fakes the home directory, so it no longer reads a real ~/.kiro.
    • Agent context budget fails with claudeSystemAppendBytes: 5135 -> 5258. That growth comes from v2/kiro-acp compared with main, not from this PR, which doesn't touch agent context. It clears when the base branch picks up main.

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

🤖 Generated with Claude Code

pedrocostadev and others added 2 commits October 29, 2026 16:09
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 30, 2026
Kiro reader resolves ~/.kiro via HostProcess.HomeDirectory; test read real home.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@maria-rcks

Copy link
Copy Markdown
Collaborator

Note

Written by gpt-6.1-sol on behalf of Maria

dry-run draft, no action taken.

closure is warranted under the prior approval rule. The PR adds Kiro historical credit accounting, contract fields and web/mobile billing presentation; discussion #27621 leaves design questions open and the body states there is no maintainer approval.

Obtain maintainer agreement on the credit-accounting schema and presentation in #27621 and link the approved scope; draft status does not defer this requirement.

@maria-rcks maria-rcks closed this Oct 31, 2026
brandonvincitore added a commit to brandonvincitore/t3code that referenced this pull request Nov 9, 2026
Add native workspace discovery, MCP reconnection controls, native session ownership guards, Specs, Powers, memory, account-priced titles, and credit history. This checkpoint is pending combined validation.

Credit history adapted from pingdotgg#27619 (e4dac3c).

Co-authored-by: Pedro Costa <[email protected]>
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.

2 participants