Repository navigation
feat: report subagent credit usage alongside elapsed time - #8003
welikoiwanenko wants to merge 1 commit into
Conversation
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
1dcffc7 to
6bb4677
Compare
UX Review (Fable 5, fork) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS "Credit usage not reported" reads as a fault line on every expanded card for providers that never bill credits, and no first-time reader has seen either new string. Watch
Suggestions
[UX-REVIEWED] 1484bb0 |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the two attached screenshots actually show the expanded managed-card usage line in both states — "Used … credits" and "Credit usage not reported" — since that expanded row is the only new visual surface. [DESIGN-REVIEWED] 1484bb0 |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the accumulated credit total matches real provider billing on a live paid run — the author explicitly deferred that ("Live provider billing verification remains for maintainers"; no paid subagent calls were used). Every inventory item has a named harm (per-run cost attribution, issue #4721), a live consumer count, and sits at cause level: credits are accumulated at the provider-billing source per attempted turn rather than patched onto the success path. The Inventory (10 items) — 10 justifiedIntent: Show credits consumed by each managed subagent beside its terminal elapsed time (ADDITION).
[FIRST-PRINCIPLES-REVIEWED] 1484bb0 |
Opus 5 Review (fork) — ✅ no blocking findingsReviewed Review detailsTwo spec/output-contract mismatches the PR's own added prose contradicts. FINDING — docs/system-specs/modules/subagent.md:782 — the owning spec still documents FINDING — src/kiro_crew/mcp_tools/spawn.py:1135 — [OPUS-REVIEWED] 1484bb0 |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
6bb4677 to
e3d8211
Compare
a1aeb5b to
63a6148
Compare
845224a to
1bfa611
Compare
|
@welikoiwanenko Thanks for this. Keeping it: it is the only implementation of #4721, and nothing on #9008 (@javenciu) inserts at the exact line this PR does: #9101 (@Premshay) is much smaller (5 files against 27 here) and collides only textually: both add a field to the Please rebase either way: at audit time the branch was 46 commits behind Posted from the 2026-09-08 open-PR relationship audit (read-only, one auditor per PR); reply here if any of this is wrong. |
1bfa611 to
459187c
Compare
459187c to
5bac35e
Compare
a7b5f0f to
318c9ff
Compare
I see one MR already landed, any updates on the second one? |
|
#9101 has now merged. #9008 remains open and blocked on its own terminal-report hold fixes, so it has not reached the point where #8003 can safely rebase onto its guarded reporter. Once #9008 lands, I’ll rebase #8003 and re-place the credit settlement and |
Attribute reported credits to managed subagent runs, including failed and cancelled attempts, so users and parent agents can compare their costs. Reuse shared turn billing, preserve terminal usage in delivery/failure tombstones, and show it across completion events, status queries, and dashboard cards without delaying parent delivery.
|
Thanks for this contribution, @welikoiwanenko! Your work on reporting subagent credit usage alongside elapsed time is landing. To let a clean same-repo CI wave run (fork PRs cannot exercise every review lane), your commit has been carried into an in-repo replacement PR — #14913 — with your authorship preserved ( Two review findings surfaced during drive-to-green and were addressed in the replacement, both preserving the intent of your change:
Closing this in favor of #14913. Full credit for the feature is yours — thank you! |
Problem / Motivation
Goal: Show the credits consumed by each managed subagent alongside its terminal elapsed time.
Managed subagent completion reports elapsed time but not the credits consumed by that run. Parents and users cannot attribute the cost of a successful, failed, or stopped subagent without comparing noisy account-level totals.
For maintainer approval: cumulative positive reported credits appear in expanded Subagents activity cards, with elapsed time retained in compact headers and usage included in completion messages and
spawn_status.Why it matters
A failed or stopped attempt can consume credits even when it produces no final answer. Per-run attribution makes those costs visible, including billed transient retries, without relying on unrelated activity in the same account.
Not a goal
What changed (motivation → approach → change)
TurnUsagerepresentation per attempted provider turn. Completion events supply usage on success; the shared billing resolver supplies fresh usage on interrupted or failed attempts. Each attempt settles once, including cancellation during event handling and force-reaping.spawn_statusresponses. Parent delivery does not wait for a new post-completion state write.subagent_doneframes so dashboard reconnects retain terminal usage. Legacy retained records remain readable without invented fields.Used … credits. Compact headers continue to show elapsed time. Backend summaries switch to minutes and seconds at 60 seconds and retain the existing credit precision.No dependency, configuration, schema migration, model-default, or changelog changes. Native harness subagents remain unattributed because they share the parent's billed turn. Providers that do not report credit billing return zero; displays omit that credit label rather than claim the run was free. This feature does not estimate charges or add dollar billing. Run totals are completion summaries, not additional billing-ledger entries; failed-attempt credits can make them larger than successful-turn records alone.
Backwards compatibility
Compatible: existing providers and retained records without credit data continue to render elapsed time without inventing usage.
Tests
Manual verification
Rendered the current production
ActivityViewercomponent with fixture-only state and captured expanded successful, failed, and stopped cards in dark and light themes. Verified credit-only expanded copy, elapsed-only compact headers, minute formatting, and narrow activity-rail layout. No live gateway or paid subagent calls were used. Live provider billing verification remains for maintainers.Screenshots / video
Fixture data rendered by the current component; each card shows its own terminal usage.
Related Issues
Implements the credit-attribution request in #4721. The issue has an earlier automated claim; this PR is for coordination and maintainer approval, not an assertion that design approval has already been given.
Fixes #4721
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
The repository's contribution terms remain unchanged; no additional declaration is made here.