Repository navigation
fix(agent): count shell failure streaks per program, not per tool - #4527
Conversation
|
Verdict: Approve with suggestions The agent was ending its turn when it tried several different shell programs and each was refused, because every shell command counted toward one shared "same tool keeps failing" streak. Streaks are now counted per program, so an agent exploring
Real-world evidenceN/A: no evidence bundle for this run. This is an internal agent-loop guard change with no CLI, API, or UI surface of its own, so the verdict rests on static review. The PR's SWE-bench result (pylint-4970: 0/3 before, resolved after) is a single task, as the author notes. I couldn't run the unit tests here because the runner lacks the dev dependencies. 🔍 Technical detailsIssues 🟢 Correction text reads as a whole-shell ban ( 🟢 Program extraction edge cases (
Skipping leading 🟢 Keying applies to any tool with a string Strengths
|
The turn-scope guard ends a turn when one tool keeps failing with new arguments. A shell tool runs many programs, so 'python -c' refused, then ls denied outside the sandbox, then pip refused counted as one tool failing four times, and a SWE-bench task was ended before any edit was made. A shell line's streak is now keyed on the program it runs; a single program refused with new arguments still stops as before.
57a1615 to
ff8ed0b
Compare
…md#4536) A failed tool call is shown once and then scrolls up the conversation, so the agent walked into the same wall again several steps later: 22% of failed calls in 32 SWE-bench task runs repeated a failure from earlier in the same task. Now each failure is recorded as a lesson: what failed and why, plus what later worked for that program. The full list rides on every later failed result, so the agent sees it exactly when it is exploring. Lessons come only from the harness's record of what ran, never from content a tool returned, and they last for the turn. | 6 hard SWE-bench tasks, DeepSeek V4.1 Flash | without (2 runs) | with | |---|---|---| | Repeated failures / failed calls | 6/22, 5/23 | **1/13** | | Steps | 215, 233 | 201 | | Solved | 2/6, 3/6 | 3/6 | | Cost | $0.52, $0.68 | $0.55 | It cuts the waste it targets without adding prompt text or model calls. It doesn't by itself solve more tasks. Depends on amd#4527, which adds the per-program key this uses. The first commit here is amd#4527's; review the second. ## Test plan - [ ] `python -m pytest tests/unit/agents/test_task_lessons.py tests/unit/agents/test_turn_scope.py`
The turn guard ends a turn after the same tool is refused four times in a row. It counted every shell command as one tool, so an agent that tried
python, thenls, thenpipand was refused each time looked like it was stuck in a loop, and its turn ended. On a SWE-bench pylint task this ended the run with no patch. Streaks are now counted per program run through the shell (a leadingcd <dir> &&is skipped), so a real loop on one program still ends the turn and trying different programs doesn't.The data is a single task. The same pylint task (pylint-4970, DeepSeek V4.1 Flash) ended with no patch in all 3 runs made with the guard (#4480) before this change, and was resolved in the run after it.
Test plan
python -m pytest tests/unit/agents/test_turn_scope.py