Skip to content

Delegate cost reporting: use canonical cumulative format#627

Merged
gnovak merged 1 commit into
devfrom
delegate-cost-reporting-cumulative
May 27, 2026
Merged

Delegate cost reporting: use canonical cumulative format#627
gnovak merged 1 commit into
devfrom
delegate-cost-reporting-cumulative

Conversation

@gnovak

@gnovak gnovak commented May 27, 2026

Copy link
Copy Markdown
Owner

Per the design discussion in chat: delegate should look like calling the individual steps in sequence. Per-step cost on Stage 1, 3, 3a, 3c already worked. What was wrong was the trailing "Delegate Stages 1-3c Aggregate Cost" block.

Two problems with the old aggregate block

  1. Bespoke label format — different from what individual /agent-* invocations emit
  2. Used per-step cost format internally — bold `$X.XX` is the marker that the cumulative-cost scanner picks up as a prior step. The aggregate would have been double-counted on any subsequent /agent-* on the same issue → guaranteed quadratic growth

Fix

Each per-step cost block in delegate now carries a canonical cumulative table appended (via `compute_cumulative_table` from `lib/cumulative_cost.py` — the same code individual invocations use). Cumulative is empty on Stage 1 (no prior cost markers); from Stage 3 onward it includes all prior delegate stages. The cumulative on the last reported stage IS the running total — no aggregate block needed.

Council reviewer comments (Stage 2, 3b) intentionally remain cost-table-less per the existing decision: their costs are small and reporting them would just be noise. Their costs won't appear in the cumulative, which matches the "what shows in the cumulative is exactly what was reported per-step" rule.

No new cost-reporting code paths — this just routes delegate through the existing per-step + cumulative formatting that resolve/design/review already use. The `_build_stage_cost_block` helper added in `workshop.py` is a thin wrapper that calls `_build_cost_table` + `compute_cumulative_table`.

`run_delegate` gains two parameters (`github_repo`, `issue_number`) so the cumulative scanner can fetch prior comments. The workflow passes them in from the same env vars it already uses.

Test plan

  • 662 unit tests pass
  • Next `/agent-delegate` run should show: Stage 1 with per-step cost only; Stages 3/3a/3c each with per-step cost + Cumulative (N steps) block; no separate Aggregate Cost comment

🤖 Generated with Claude Code

…e aggregate

Per the design discussion: delegate should look like calling the
individual steps in sequence. Per-step cost on Stage 1, 3, 3a, 3c
already worked. What was wrong was the trailing "Delegate Stages 1-3c
Aggregate Cost" block, which:

1. Used a bespoke label format different from individual /agent-*
   invocations.
2. Contained a per-step-format cost table (with bold **$X.XX**) that
   the cumulative-cost scanner would have picked up as a prior step
   cost — guaranteeing quadratic double-counting on any later
   /agent-* on the same issue.

Replaced with: each per-step cost block in delegate now carries a
canonical cumulative table appended (via compute_cumulative_table from
lib/cumulative_cost.py — the same code individual invocations use).
Cumulative is empty on Stage 1 (no prior cost markers); from Stage 3
onward it includes all prior delegate stages. The cumulative on the
last reported stage IS the running total, no aggregate block needed.

Council reviewer comments (Stage 2, 3b) intentionally remain
cost-table-less — those costs are small and the user has decided they
would just be noise. Their costs won't appear in the cumulative, which
matches the "what shows in the cumulative is exactly what was reported
per-step" rule.

No new cost-reporting code; this just routes delegate through the
existing per-step + cumulative path that resolve/design/review already
use. The `_build_stage_cost_block` helper added in workshop.py is a
thin wrapper that calls _build_cost_table + compute_cumulative_table.

run_delegate gains two parameters (github_repo, issue_number) so the
cumulative scanner can fetch prior comments. The workflow passes them
in from the same env vars it already uses elsewhere.

662 tests pass.
@gnovak gnovak merged commit eefa7c7 into dev May 27, 2026
@gnovak gnovak deleted the delegate-cost-reporting-cumulative branch June 13, 2026 03:43
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.

1 participant