Repository navigation
feat(agent): a failed call carries what the task has already learned - #4536
Conversation
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.
Across 32 SWE-bench task runs, 22% of failed tool calls repeated a failure the agent had already hit in the same task. Each failure is now recorded as a lesson (what failed, why, and what later worked for that program), and the list rides on every later failed result, so the constraints learned so far are in view exactly when the agent is exploring.
|
Verdict: Approve with suggestions When a tool call fails, the agent now also sees a short list of what has already failed earlier in the turn, and what later worked. This targets a measured problem: the agent kept repeating failures it had already hit. The change is small, capped at 8 lessons, and reset each turn, and the PR's SWE-bench numbers show repeated failures dropping. Nothing blocks merge.
Real-world evidenceN/A: no evidence bundle was produced for this run. The change is inside the agent loop and has no CLI, API, or UI surface of its own. The PR's SWE-bench table is the behavioural evidence. I couldn't run the unit tests here (pytest isn't installed in the review sandbox), so the verdict rests on static review plus that table. 🔍 Technical detailsScope: reviewed the second commit ( 🟡 Lesson text is tool-returned content ( (Or, if the guarantee matters: store only 🟢 Lessons persist across mutating calls, but the guard's streaks don't 🟢 Retried successes overwrite Strengths
|
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.
It cuts the waste it targets without adding prompt text or model calls. It doesn't by itself solve more tasks.
Depends on #4527, which adds the per-program key this uses. The first commit here is #4527's; review the second.
Test plan
python -m pytest tests/unit/agents/test_task_lessons.py tests/unit/agents/test_turn_scope.py