Repository navigation
Description
What happened
The second review run on PR #6769 (run 33317698843) produced a valid agent-result.json with 5 findings and the review was successfully posted. However, the run's metrics.json reports num_turns: 0 and total_cost_usd: 0, and the telemetry span records exit_code: -1 and finish_reason: "error". The job step itself completed as success. This means the agent process terminated abnormally after writing its output but before metrics were flushed, making cost tracking unreliable for this run.
What could go better
Cost and usage metrics should be reliable for every run that produces valid output. When the agent crashes after writing results, the metrics file should still reflect the actual work performed. The zeroed metrics mean this run's cost does not appear in aggregate reporting, understating actual spend. Confidence is moderate — the root cause could be a crash in a post-output verification step (the agent ran fullsend-check-output or a subsequent Bash call that failed), or the metrics flush could depend on a clean exit that the error path bypasses. Related but distinct from #3548, which describes a Failure status despite valid output (inverse symptom — there the status was wrong; here the status was correct but metrics were lost).
Proposed change
Investigate the review agent runner's metrics collection path in the fullsend CLI. The metrics flush should happen before or atomically with the output write, not after a post-validation step that can fail. If fullsend-check-output or any post-output step fails, the error should be logged but should not prevent metrics from being persisted. The telemetry span should capture actual token counts from the API responses regardless of the agent's exit code. Look at the metrics collection in the harness runner (likely internal/harnessdispatch/ or the runner entrypoint) to ensure metrics are flushed before any post-output validation.
Validation criteria
Review agent runs that produce valid agent-result.json output should report non-zero num_turns and total_cost_usd in metrics.json, even when the agent process exits with a non-zero exit code. Verify by checking the next 10 review runs that complete with exit_code=-1 — all should have populated metrics.
Generated by retro agent from #6769
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn progress
Activity
fullsend-ai-triage commentedon Aug 31, 2026
🤖 Finished Triage · ✅ Success · Started 3:38 PM UTC · Completed 3:43 PM UTC
Commit:
32ad401· View workflow run →Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $0.67
fullsend-ai-triage commentedon Aug 31, 2026
Re-checked relevance as requested: this remains a valid, distinct gap and should stay open for human prioritization rather than being auto-implemented right now.
Since this issue was filed, PR #6908 (closing #6905) and PR #6938 (closing #6936) landed and fixed the closely related cancellation-metrics problem:
InputTokens/OutputTokens/cache counters are now captured incrementally via aTokensEventhandler so they survive a run that never reaches Claude's terminalresultevent, and the agent-iteration loop now finalizes metrics/spans before extraction when a run is cancelled.However, both of those PRs explicitly leave
NumTurnsandTotalCostUSDsourced only from that terminalResultEvent-- confirmed by readinginternal/runtime/claude.goon currentmain. That is precisely the symptom this issue reports (num_turns: 0,total_cost_usd: 0,exit_code: -1) for a run whose process ended abnormally for reasons other than a GitHub Actions cancellation, after valid output had already been produced. So the underlying problem is narrower than when filed, but not resolved.One correction to the prior triage pass: the relevant code lives in
internal/runtime/claude.goand the iteration loop ininternal/cli/run.go, notinternal/harnessdispatch/.Note: this triage run intentionally withholds a recommendation to auto-implement, per the request to leave this for human prioritization. This repository's current auto-code configuration promotes bug-category issues mechanically regardless of that preference, so please double check the issue's labels after this triage completes and manually hold it back if it gets auto-promoted.
Next steps:
/fs-code— agent creates a PR to implement this issue/fs-code <your instruction>— agent implements with your specific guidancePrevious run
Severity: medium — cost tracking reliability is impacted but agent output and reviews are unaffected.
Related issues
Investigation pointers
The metrics collection likely lives in the harness runner entrypoint — start with
internal/harnessdispatch/and trace howmetrics.jsonis written relative to the agent process lifecycle. Key question: does the runner write metrics in adeferblock (which would survive panics) or in a sequential step after post-output validation (which wouldn't)?Proposed test
Labels: Review agent metrics bug affecting the harness runner component, medium priority since it impacts cost reporting but not agent functionality.
Next steps:
/fs-code— agent creates a PR to implement this issue/fs-code <your instruction>— agent implements with your specific guidancefullsend-ai-coder commentedon Aug 31, 2026
🤖 Finished Code · ✅ Success · Started 3:44 PM UTC · Completed 4:04 PM UTC
Commit:
32ad401· View workflow run →Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $5.52
ralphbean commentedon Sep 24, 2026
/fs-triage lots of things have changed between when this was originally filed and now across both the https://github.com/fullsend-ai/fullsend and https://github.com/fullsend-ai/agents repos. Is this still relevant? This is a stale-issue review, not an implementation request: even if the issue is still a valid bug and has sufficient information, do not recommend or trigger ready-to-code yet. Leave it for human prioritization after confirming whether it remains relevant. Do not close a still-relevant bug merely to avoid coding it.
fullsend-ai-triage commentedon Sep 24, 2026
🤖 Finished Triage · ✅ Success · Started 6:38 PM UTC · Completed 6:45 PM UTC
Commit:
fbf65c8· View workflow run →Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $0.64
fullsend-ai-coder commentedon Sep 24, 2026
🤖 Finished Code · ✅ Success · Started 6:47 PM UTC · Completed 7:11 PM UTC
Commit:
fbf65c8· View workflow run →Runtime: pi · Model: xai/grok-4.6 · Effort: high · Cost: $12.38
refactor(#6806): guard applyClaudeMetrics against a nil *RunMetrics