fix(agent): expand repeatSuccessSignature to track all tools (anti-loop)#3478
fix(agent): expand repeatSuccessSignature to track all tools (anti-loop)#3478gelutjari wants to merge 1 commit into
Conversation
SivanCola
left a comment
There was a problem hiding this comment.
Thanks for the tight patch. I think this needs one correction before merge.
bash is intentionally ReadOnly() == false because arbitrary shell commands may write, but repeatSuccessSignature() previously narrowed the repeat-success guard back down with isShellFileWriteCommand(). Removing that filter makes every repeated foreground bash command count as a write-like success, so non-writing verification commands such as go test ./internal/agent, git status, or pwd are blocked on the third identical successful call in the same user turn, even when rerunning the command is legitimate after intervening state changes.
This already regresses the existing focused test on the PR head:
go test ./internal/agent -run TestRepeatGuardAllowsRepeatedNonWritingBashCommand -count=1fails withbash executed 2 times, want 3 for non-writing commands
Please keep the bash guard limited to known write commands, or replace it with a more precise classification that still allows repeated non-writing verification commands. If the goal is to cover remember/forget and other non-read-only tools, please also add/update focused coverage for those intended loop cases without regressing the existing bash behavior.
Once this is addressed and CI stays green, I will consider merging it into main-v2.
…nerMaxSteps unlimited - repeatSuccessSignature: track remember/forget tools in write-file case - bash case: keep isShellFileWriteCommand filter (non-writing bash not blocked) - default case: catch-all tracking prevents tool loops for any tool - PlannerMaxSteps: 0 = unlimited, respect user's configured value All existing tests pass. 3 new tests added: - TestRepeatGuardBlocksRepeatedRemember - TestRepeatGuardBlocksRepeatedForget - TestRepeatGuardBlocksRepeatedUnknownTool
4ff6446 to
84ce660
Compare
|
@SivanCola Thanks for the thorough review. All 3 concerns addressed: Changes1.
|
| Tool | Tracked? | Blocked after 2 identical? | Rationale |
|---|---|---|---|
write_file, edit_file, multi_edit, notebook_edit |
✅ Yes | ✅ Yes | File writes should not repeat |
remember, forget |
✅ Yes | ✅ Yes | Memory ops with identical args are wasteful |
bash (file-write) |
✅ Yes | ✅ Yes | e.g., python -c "open('f','w').write(...)" |
bash (non-writing) |
❌ No | ❌ No | go test, git status may legitimately repeat |
bash (background) |
❌ No | ❌ No | Background jobs are fire-and-forget |
todo_write, complete_step, etc. |
✅ Yes (catch-all) | ✅ Yes | Prevents stuck planning loops |
Read-only tools (read_file, grep, etc.) |
❌ No | ❌ No | t.ReadOnly() → skipped early |
Closing this PR. PlannerMaxSteps fix has already been merged upstream via #3532 (more complete implementation with config field + Desktop UI). Will open a new focused PR for the remaining anti-loop guard defense-in-depth fixes (remember/forget tracking, bash regression fix, catch-all default case).