Skip to content

Wire live worker usage into cost reporting - #245

Closed
ndycode wants to merge 3 commits into
jcast90:mainfrom
ndycode:fix/live-worker-cost-capture
Closed

ndycode wants to merge 3 commits into
jcast90:mainfrom
ndycode:fix/live-worker-cost-capture

Conversation

@ndycode

@ndycode ndycode commented Aug 30, 2026

Copy link
Copy Markdown

Summary

  • Request Claude stream-json output in the live WorkerSpawner path, route it through the shared parser, and retain bounded human-readable assistant/diagnostic tails while only detecting PR URLs in parsed assistant text.
  • Record one classified live-worker cost entry per completed call. Claude's latest total_cost_usd is treated as a client-side estimate and used once when available; Relay's token-price table is only the fallback, so the two sources are never added together.
  • Preserve failure, cancellation, partial-output, stderr, and worktree-cleanup behavior; reject unsafe numeric/output sizes; document the observational (not billing-authoritative) cost semantics.

Closes #243

Test plan

  • pnpm test (1,248 passed, 29 skipped)
  • pnpm typecheck
  • pnpm build
  • pnpm format:check
  • cargo check --workspace --locked
  • cargo test -p harness-data (91 passed)
  • cd gui && pnpm build
  • HARNESS_LIVE=1 ./node_modules/.bin/vitest run test/integration/live-worker-cost.test.ts (real autonomous handler -> Claude -> cost ledger -> rly cost)
  • Focused fake-worker and regression coverage for parsed assistant/result output, PR URL detection, malformed and non-JSON diagnostics, partial/oversized output, missing/unsafe usage, provider-only cost, failures, stop behavior, task classification, and cost-source precedence

Size check

Diff size: 1004 lines added / 95 deleted.

This exceeds 800 lines because 724 additions are focused regression and opt-in integration tests. The production/documentation change is 280 additions and 66 deletions across the existing worker, parser, cost-ledger, ticket-classification, and mirrored type paths; it does not introduce a parallel parsing or orchestration framework.

Breaking changes?

No. The new ticket taskType field is optional and the Rust mirror uses a default for existing serialized tickets. Existing non-JSON diagnostics and failure/cleanup behavior remain supported.

AI-assisted?

Yes. OpenAI Codex provided substantial assistance with investigation, implementation, tests, and review. Every commit includes the required Co-Authored-By: OpenAI Codex <noreply@openai.com> footer. The final diff was reviewed and validated at commit 666f4826b31dd1ea675475ff0ac8032609c4c7fd.

ndycode and others added 3 commits August 31, 2026 02:37
The autonomous WorkerSpawner path bypassed the existing stream parser and task cost ledger, so production runs emitted no cost data. Parse Claude stream-json in the live worker, retain readable diagnostics and PR detection, and persist one provider-estimated cost per classified ticket.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Bound retained stream state, preserve distinct terminal output, record positive provider estimates without token metadata, and keep seeded autonomous tickets classified for cost reporting.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Cap partial stream lines and diagnostic tails, validate numeric cost inputs before persistence, and only accept PR URLs from parsed assistant text. Document that cost reporting remains observational.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
@ndycode
ndycode requested a review from jcast90 as a code owner August 30, 2026 19:46
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@ndycode ndycode closed this by deleting the head repository Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cost: wire the live worker path — rly cost reports nothing until this lands

1 participant