Repository navigation
Conversation
on_setup_attempt folds the finished attempt's cost into _previous_cost but never resets _cost, even though every retry attempt starts from a fresh agent whose instance_cost starts at 0 again. The status line shows _previous_cost + _cost, so until the new attempt's first step completed, each status line displayed the previous attempt's cost twice (roughly 2x the actual spend in the batch progress UI).
chessing234
left a comment
There was a problem hiding this comment.
Reviewed the retry lifecycle and cost folding/reset. The focused status-hook regression test passes.
No blocking issue found in the reviewed diff. Validation was limited to the focused checks described above; the full integration suite was not run.
chessing234
left a comment
There was a problem hiding this comment.
Requesting changes as a reviewer-directed hold pending specific revision requirements. No additional technical defect is asserted in this follow-up; the findings and validation limits in my earlier review still apply.
chessing234
left a comment
There was a problem hiding this comment.
Reviewed retry-attempt cost accumulation and reset against the lifecycle call sites. The status-hook regression test passed.
No new blocking defect found in this review. These were focused local checks; the full integration suite was not run.
|
Thanks for taking a look, and sorry for the slow reply on our side. Status right now: head is We're treating the 2026-10-05 hold as still in force. Your note mentions "specific revision requirements", but we can't find them written down anywhere on this PR, and we'd rather ask than guess at what you meant. Could you tell us whether there is anything specific we should do to lift the hold? If so, please spell it out and we'll do it. We're also happy to run the full integration suite if that would help. |
Reference Issues/PRs
Fixes #1567
What does this implement/fix? Explain your changes.
Summary
SetStatusAgentHookrenders the per-instance status line in the batch progress UI. On a retry attempt it double-counted the previous attempt's spend until the new attempt's first step completed, so the status line showed roughly 2x the actual spend (e.g.Attempt 2 Step 1 ($2.00)when only $1.00 had been spent).Why (root cause)
sweagent/run/run_batch.py:347attaches aSetStatusAgentHookto every batch agent. With a retry loop,RetryAgent._next_attempt(sweagent/agent/agents.py:321) re-attaches the same hook objects to a freshDefaultAgent, whosesetupfireson_setup_attempt(sweagent/agent/agents.py:594) at the start of every attempt. Inon_setup_attempt(sweagent/agent/hooks/status.py:16-20) the finished attempt's cost was folded into_previous_cost:but
self._costwas never reset, even though the comment says it would be. Because the status line shows${self._previous_cost + self._cost:.2f}(sweagent/agent/hooks/status.py:29), every status line of the new attempt displayed the previous attempt's spend twice untilon_step_done(sweagent/agent/hooks/status.py:31) overwrote_costwith the new attempt'sinstance_cost. The previous+current split only yields the true total spend if_costis zeroed at the attempt boundary.Changes
sweagent/agent/hooks/status.py: resetself._cost = 0.0inon_setup_attemptright after folding the finished attempt's cost into_previous_cost, so_previous_cost + _costis the true total spend from the first status line of a retry attempt onward. For non-retry agents this is a no-op (_costis still0.0at the singlesetupcall).tests/test_agent_hooks.py: new regression test that drives the hook through two attempts and asserts the status line shows$1.00(not$2.00) at the start of attempt 2, and$1.25after attempt 2's first step adds $0.25.Testing
New regression test, failing on
main(3ea751c):Passing with this fix:
Existing tests around the changed module:
Lint/format (pre-commit config, ruff):
Note: in the sandbox used for this work, the GitHub-API/network-dependent tests (
tests/test_run_hooks.pyshould_open_pr tests,tests/test_env_utils.py::test_get_associated_commit_urls,tests/test_run_replay.py::test_replay) fail or stall identically on unpatchedmain, so they could not be exercised here; they are unaffected by this change (no code path they use was modified).