agent always trips itself up with ruff #8077

Open
opened 2026-02-16 18:09:06 -05:00 by yindo · 0 comments
Owner

Originally created by @ferdinandyb on GitHub (Jan 30, 2026).

Description

When writing python, the ruff formatter strips unused imports from the file. Unfortunately, the agent just loves to first add ONLY the imports (which get stripped by ruff), then add the usage, resulting in an error when trying to use an undefined symbol.

The obvious solution would be to tell the agent to add these in at once, but it can't because the edit tool doesn't work that way (i.e. import at top, usage in middle, while the edit tool edits on contiguous block).

I saw in the codebase there is an unregistered multiedit tool, but I think a simple fix would be adding something like this to the edit tools description:

- Language specific formatters run after every edit. These may remove imported
  but unused symbols. Always add symbol usage first, and imports later.

Plugins

OpenCode version

1.1.44

Steps to reproduce

try editing python with ruff

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Originally created by @ferdinandyb on GitHub (Jan 30, 2026). ### Description When writing python, the `ruff` formatter strips unused imports from the file. Unfortunately, the agent just _loves_ to first add ONLY the imports (which get stripped by ruff), then add the usage, resulting in an error when trying to use an undefined symbol. The obvious solution would be to tell the agent to add these in at once, but it can't because the edit tool doesn't work that way (i.e. import at top, usage in middle, while the edit tool edits on contiguous block). I saw in the codebase there is an unregistered multiedit tool, but I think a simple fix would be adding something like this to the edit tools description: ``` - Language specific formatters run after every edit. These may remove imported but unused symbols. Always add symbol usage first, and imports later. ``` ### Plugins - ### OpenCode version 1.1.44 ### Steps to reproduce try editing python with ruff ### Screenshot and/or share link _No response_ ### Operating System _No response_ ### Terminal _No response_
yindo added the bug label 2026-02-16 18:09:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8077