feat: report subagent credit usage alongside elapsed time - #8003
feat: report subagent credit usage alongside elapsed time#8003welikoiwanenko 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 The diff, PR body, base-tree string usage, and screenshot availability are all established. The only user-visible dashboard change is one line in the expanded subagent card, reusing the existing localized UX-Verdict: CONCERNS "Turn took…" now labels a run-cumulative total; the new credit line's screenshots exist only on the fork, unseen by any first-time reader. Watch
Evidence gaps
Suggestions
[UX-REVIEWED] 1bfa611 |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Verification complete. The design rests on existing contracts ( Design-Verdict: PASS Attribution rides existing billing seams end-to-end; the settle-once accounting and widened writer holds map to real, tested hazards, not invented ones. Suggestions
[DESIGN-REVIEWED] 1bfa611 |
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of All verifications are done: the frontend reuses the existing First-Principles-Verdict: CONCERNS
Not justified as shipped
What this change shipsIntent: let parents and users see what a subagent run cost, per run, at completion — an ADDITION (linked feature request #4721).
WatchThe failed-attempt accounting rests on "providers replace this holder for each prompt" — verified for ACP ( Subtractions
[FIRST-PRINCIPLES-REVIEWED] 1bfa611 |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
6bb4677 to
e3d8211
Compare
dd99628 to
1630c44
Compare
77c8d40 to
e092b20
Compare
e092b20 to
a1aeb5b
Compare
a1aeb5b to
63a6148
Compare
63a6148 to
845224a
Compare
Attribute reported credits to managed subagent runs, including failed and cancelled attempts, so users and parent agents can compare their costs. Persist terminal usage and show it in completion events, status queries, and dashboard cards. Bound best-effort persistence before parent delivery and settle active accounting before reap reports capture their totals.
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. |
Problem / Motivation
Managed subagent completion currently 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.
What changed (motivation → approach → change)
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.
Tests
Added regression coverage for successful and failed attempts, billed retries, cancellation during consumer work, force-reaping during a state-write drain, stalled and late-failing terminal persistence, overlapping writer holds, restart/status compatibility, MCP error and paging responses, completion digests, Redux terminal events, and activity-card rendering.
On the rebased head, 601 focused backend tests passed across every changed backend test file plus the ACP frame-replay regression suite. The two changed frontend suites passed 73 tests; TypeScript, ESLint, documentation lint, and diff checks also passed. The full repository suite was not rerun locally; CI remains the authoritative full-matrix validation.
Manual verification
Rendered the real production SPA with the repository's scripted Playwright harness and fixture-only HTTP/WebSocket responses. Verified expanded elapsed-and-credit summaries and elapsed-only headers for completed, failed, and stopped subagents in dark and light themes, including a constrained 320px activity region. No live gateway or paid subagent calls were used. Live provider billing verification remains for maintainers.
Screenshots / video
Fixture data, real built dashboard; each card shows its own terminal usage.
Full dashboard context
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.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)Fixes #4721