Run formatters only on session end instead of after tool call #1678

Closed
opened 2026-02-16 17:32:07 -05:00 by yindo · 10 comments
Owner

Originally created by @remorses on GitHub (Sep 10, 2025).

Originally assigned to: @thdxr on GitHub.

Now formatters confuse the LLM too much. Running formatting on session end would give most of the benefits without penalizing tool calls success rate in the same message

Originally created by @remorses on GitHub (Sep 10, 2025). Originally assigned to: @thdxr on GitHub. Now formatters confuse the LLM too much. Running formatting on session end would give most of the benefits without penalizing tool calls success rate in the same message
yindo closed this issue 2026-02-16 17:32:07 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Sep 10, 2025):

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

  • #2529: Discusses the exact same problem of formatters confusing the LLM and causing edit failures due to the model receiving formatted tool output different from what it generated

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

@github-actions[bot] commented on GitHub (Sep 10, 2025): This issue might be a duplicate of existing issues. Please check: - #2529: Discusses the exact same problem of formatters confusing the LLM and causing edit failures due to the model receiving formatted tool output different from what it generated Feel free to ignore if none of these address your specific case.
Author
Owner

@remorses commented on GitHub (Sep 11, 2025):

Another way to mostly solve this: format files on read tool calls before returning them to the model.

@remorses commented on GitHub (Sep 11, 2025): Another way to mostly solve this: format files on read tool calls before returning them to the model.
Author
Owner

@rekram1-node commented on GitHub (Sep 11, 2025):

@remorses I think that is kinda existing behavior tho no?

LLM reads file
LLM edits file
formatter runs
LLM tries to edit file
LLM must re-read file
...

@rekram1-node commented on GitHub (Sep 11, 2025): @remorses I think that is kinda existing behavior tho no? LLM reads file LLM edits file formatter runs LLM tries to edit file LLM must re-read file ...
Author
Owner

@remorses commented on GitHub (Sep 11, 2025):

I mean formatting the file on read operations. this way the LLM will probably use same conventions, there is less risk of big changes after formatting. code outside of the replaced snippet is guaranteed to be formatted

@remorses commented on GitHub (Sep 11, 2025): I mean formatting the file on read operations. this way the LLM will probably use same conventions, there is less risk of big changes after formatting. code outside of the replaced snippet is guaranteed to be formatted
Author
Owner

@thdxr commented on GitHub (Sep 11, 2025):

im thinking maybe at the end of a message (when agent is done) we go through all edit tool calls and format the file?

if they try to edit again they are told the file is modified so they will reread it

@thdxr commented on GitHub (Sep 11, 2025): im thinking maybe at the end of a message (when agent is done) we go through all edit tool calls and format the file? if they try to edit again they are told the file is modified so they will reread it
Author
Owner

@remorses commented on GitHub (Sep 12, 2025):

That would be much better than now (I would prefer it disabled by default tho)

I want to keep git diff as a way to see what the model changed and it it starts formatting files the diff gets crowded

@remorses commented on GitHub (Sep 12, 2025): That would be much better than now (I would prefer it disabled by default tho) I want to keep git diff as a way to see what the model changed and it it starts formatting files the diff gets crowded
Author
Owner

@rekram1-node commented on GitHub (Sep 12, 2025):

does your editor not format on save? For me the diffs arent ever crowded because a save runs prettier, gofmt, etc

@rekram1-node commented on GitHub (Sep 12, 2025): does your editor not format on save? For me the diffs arent ever crowded because a save runs prettier, gofmt, etc
Author
Owner

@remorses commented on GitHub (Sep 12, 2025):

No, I currently use mainly Claude Code and try sometimes Opencode. I use both at the same time, so I have a lot of unformatted files

I have non formatted files for a lot of reasons. I just don't format on save. I think that's the majority of users. Now i disabled all LSP and formatters, that should be the default imo

@remorses commented on GitHub (Sep 12, 2025): No, I currently use mainly Claude Code and try sometimes Opencode. I use both at the same time, so I have a lot of unformatted files I have non formatted files for a lot of reasons. I just don't format on save. I think that's the majority of users. Now i disabled all LSP and formatters, that should be the default imo
Author
Owner

@rekram1-node commented on GitHub (Dec 27, 2025):

[automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

@rekram1-node commented on GitHub (Dec 27, 2025): [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!
Author
Owner

@remorses commented on GitHub (Dec 28, 2025):

I would like to keep this open but GithHub says I do not have the permission to do it

@remorses commented on GitHub (Dec 28, 2025): I would like to keep this open but GithHub says I do not have the permission to do it
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1678