The model loops attempting to edit files in PLAN mode #2006

Open
opened 2026-02-16 17:33:42 -05:00 by yindo · 7 comments
Owner

Originally created by @agladysh on GitHub (Oct 8, 2025).

Originally assigned to: @thdxr on GitHub.

Most often happens after switch from the BUILD mode, but also sometimes happens when starting new conversation in the PLAN mode from the get go.

Suggestion: expose the edit tool in the PLAN mode, but return a clear admonition text with a reminder to continue planning instead of trying to modify files.

Thinking...

I need to replace the counting logic. Let me replace lines 209-215 with proper logic that groups by directory and counts files correctly.
Plan grok-code (01:37 PM)

Read packages/minimal-cli/src/batch-mode.ts (limit=25, offset=205)

      // Domain objects are already validated during loading
      // Count valid review sets from domain objects

      // If we get here, everything is valid
      for (const reviewSet of reviewSets) {
        validDirs++;

Thinking...

I need to replace the counting logic. Let me replace the section from line 209 to 215 with proper counting that groups by directory.
Plan grok-code (01:37 PM)

Read packages/minimal-cli/src/batch-mode.ts (limit=25, offset=205)

      // Domain objects are already validated during loading
      // Count valid review sets from domain objects

      // If we get here, everything is valid
      for (const reviewSet of reviewSets) {
        validDirs++;

Thinking...

I need to replace the counting logic. Let me replace lines 209-215 with proper logic that groups by directory and counts files correctly.
Plan grok-code (01:37 PM)
Originally created by @agladysh on GitHub (Oct 8, 2025). Originally assigned to: @thdxr on GitHub. Most often happens after switch from the BUILD mode, but also sometimes happens when starting new conversation in the PLAN mode from the get go. Suggestion: expose the edit tool in the PLAN mode, but return a clear admonition text with a reminder to continue planning instead of trying to modify files. ``` Thinking... I need to replace the counting logic. Let me replace lines 209-215 with proper logic that groups by directory and counts files correctly. Plan grok-code (01:37 PM) Read packages/minimal-cli/src/batch-mode.ts (limit=25, offset=205) // Domain objects are already validated during loading // Count valid review sets from domain objects // If we get here, everything is valid for (const reviewSet of reviewSets) { validDirs++; Thinking... I need to replace the counting logic. Let me replace the section from line 209 to 215 with proper counting that groups by directory. Plan grok-code (01:37 PM) Read packages/minimal-cli/src/batch-mode.ts (limit=25, offset=205) // Domain objects are already validated during loading // Count valid review sets from domain objects // If we get here, everything is valid for (const reviewSet of reviewSets) { validDirs++; Thinking... I need to replace the counting logic. Let me replace lines 209-215 with proper logic that groups by directory and counts files correctly. Plan grok-code (01:37 PM) ```
Author
Owner

@github-actions[bot] commented on GitHub (Oct 8, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #2631: Subagents trying to execute destructive actions (edit/delete) in Plan Mode - Similar issue where subagents don't know about the current mode and try to edit files in PLAN mode
  • #2709: Plan Agent does modifications to files - Reports plan mode sometimes making modifications to the codebase when it shouldn't
  • #1682: BUG: dumps system prompt in an infinite loop for absolutely no reason - Shows infinite loop behavior with system prompt repetition in plan mode
  • #2052: Subagents often getting stuck into tool usage loops - Describes subagents getting stuck in tool usage loops, particularly with the read tool

The core issue appears to be that models in PLAN mode are attempting to use editing tools they shouldn't have access to, leading to repetitive behavior. Your suggestion to expose the edit tool but return an admonition text is interesting and aligns with similar requests in the linked issues.

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 8, 2025): This issue might be a duplicate of existing issues. Please check: - #2631: Subagents trying to execute destructive actions (edit/delete) in Plan Mode - Similar issue where subagents don't know about the current mode and try to edit files in PLAN mode - #2709: Plan Agent does modifications to files - Reports plan mode sometimes making modifications to the codebase when it shouldn't - #1682: BUG: dumps system prompt in an infinite loop for absolutely no reason - Shows infinite loop behavior with system prompt repetition in plan mode - #2052: Subagents often getting stuck into tool usage loops - Describes subagents getting stuck in tool usage loops, particularly with the read tool The core issue appears to be that models in PLAN mode are attempting to use editing tools they shouldn't have access to, leading to repetitive behavior. Your suggestion to expose the edit tool but return an admonition text is interesting and aligns with similar requests in the linked issues. Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Oct 8, 2025):

i think we may give model an edit tool but only let it alter .md files (maybe .txt too?) not sure yet tho

@rekram1-node commented on GitHub (Oct 8, 2025): i think we may give model an edit tool but only let it alter .md files (maybe .txt too?) not sure yet tho
Author
Owner

@agladysh commented on GitHub (Oct 8, 2025):

For my workflows that would not work, because I often plan for writing documents — and then write them in the BUILD mode. If you would allow editing in PLAN mode, then please make it configurable, so I could turn it off

@agladysh commented on GitHub (Oct 8, 2025): For my workflows that would not work, because I often plan for writing documents — and then write them in the BUILD mode. If you would allow editing in PLAN mode, then please make it configurable, so I could turn it off
Author
Owner

@rekram1-node commented on GitHub (Oct 8, 2025):

already is fully configurable you can do endless modifications

I guess I misread your initial comment, are you suggesting that we should start giving it an edit tool and tell it not to use it more clearly instead of the curretn setup (no edit tool)?

@rekram1-node commented on GitHub (Oct 8, 2025): already is fully configurable you can do endless modifications I guess I misread your initial comment, are you suggesting that we should start giving it an edit tool and tell it not to use it more clearly instead of the curretn setup (no edit tool)?
Author
Owner

@agladysh commented on GitHub (Oct 8, 2025):

Yes. Honeytrap it. Its urge to change files is unstoppable otherwise — it would find a hole (e.g. it also tries to run sed -i, git checkout etc. if it realizes edit does not work, etc. — and comes to sense immediately when slapped on the wrist)

@agladysh commented on GitHub (Oct 8, 2025): Yes. Honeytrap it. Its urge to change files is unstoppable otherwise — it would find a hole (e.g. it also tries to run `sed -i`, `git checkout` etc. if it realizes edit does not work, etc. — and comes to sense immediately when slapped on the wrist)
Author
Owner

@rekram1-node commented on GitHub (Oct 8, 2025):

Interesting idea, will probably play with that in future, rn we try to just use the permissions model so you can deny these poor attempts and then tell it not to but ofc this ux as you've found isn't perfect.

Thanks for suggestion!

@rekram1-node commented on GitHub (Oct 8, 2025): Interesting idea, will probably play with that in future, rn we try to just use the permissions model so you can deny these poor attempts and then tell it not to but ofc this ux as you've found isn't perfect. Thanks for suggestion!
Author
Owner

@guyvdb commented on GitHub (Oct 8, 2025):

My workflow is plan -> write .md of plan -> review/edit plan manually -> execute plan.

It is sometimes frustrating that when I switch to BUILD to write the plan to disk, telling agent "only write plan DO NOT START CODING", it ignores and starts coding before I have had a chance to review/edit. So having the PLAN able to write .md/.txt would be great for me.

@guyvdb commented on GitHub (Oct 8, 2025): My workflow is plan -> write .md of plan -> review/edit plan manually -> execute plan. It is sometimes frustrating that when I switch to BUILD to write the plan to disk, telling agent "only write plan DO NOT START CODING", it ignores and starts coding before I have had a chance to review/edit. So having the PLAN able to write *.md/*.txt would be great for me.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2006