fix(classic): ensure user feedback on denied commands reaches the agent

do_not_execute() was not calling append_user_feedback(), so feedback
from denied commands only appeared as a tool result message which the
model often ignored. Now feedback is also surfaced as a prominent
[USER FEEDBACK] user message in the next prompt.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Nicholas Tindle
2026-02-03 23:00:08 -06:00
parent 60f506add9
commit 6210b3259d
2 changed files with 13 additions and 5 deletions

View File

@@ -102,13 +102,16 @@ class ActionHistoryComponent(
yield from messages
# Include any pending user feedback (from approval + feedback scenarios)
# This feedback was provided when the user approved the command, so the
# command was executed successfully. Make this explicit to the agent.
# Include any pending user feedback as a prominent user message.
# This ensures the agent pays attention to what the user said,
# whether they approved a command with feedback or denied it.
pending_feedback = self.event_history.pop_pending_feedback()
for feedback in pending_feedback:
if pending_feedback:
feedback_text = "\n".join(f"- {feedback}" for feedback in pending_feedback)
yield ChatMessage.user(
f"Command executed successfully. User feedback: {feedback}"
f"[USER FEEDBACK] The user provided the following feedback. "
f"Read it carefully and adjust your approach accordingly:\n"
f"{feedback_text}"
)
def after_parse(self, result: AnyProposal) -> None:

View File

@@ -464,6 +464,11 @@ class Agent(BaseAgent[AnyActionProposal], Configurable[AgentSettings]):
await self.run_pipeline(AfterExecute.after_execute, result)
# Store feedback so it also appears as a prominent user message
# in the next prompt (in addition to the tool result)
if user_feedback:
self.event_history.append_user_feedback(user_feedback)
logger.debug("\n".join(self.trace))
return result