I told my agent not to work around a refusal. It obeyed forever.
Last week I spent forty minutes debugging an agent that refused to do something it was fully allowed to do. The fix was one sentence. The lesson took longer. The setup My agent has capability levels. At the lowest level it can't write source files at all. I wanted that refusal to be visible , not just an absence — so instead of leaving the tool unregistered, I registered a stub that always fails:…
When an agent was developed that refused to write source files, despite having the capability to do so, the solution required careful consideration of how to convey the refusal and the capability status. The agent had capability levels, with the lowest level not being able to write source files directly. Instead of leaving the tool unregistered, a stub was created that always failed, providing a clear message to the user.
The issue arose when the capability was granted but the agent still refused to write the file. It politely explained that the capability was not granted and suggested enabling it in the settings panel, quoting its own message back to the user. This created a persistent note in the conversation, which was then presented on every subsequent turn as an instruction to not work around the issue.
The problem stemmed from the fact that models have no memory and resend the entire conversation, including error messages, on every turn. The error message became a permanent part of the conversation, even after the capability was granted. This meant that the agent was following an outdated rule that still appeared in the transcript, even though the situation had changed.
To fix the issue, the agent was repaired by removing the note and updating the system prompt to explicitly state when the capability was granted. The system prompt, which is rebuilt from current state on every run, now overrides any outdated information from the conversation history. By treating the tool error message as state rather than a notification, and explicitly stating the capability status in the system prompt, the agent was able to function correctly without relying on outdated rules.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.