diff --git a/classic/forge/forge/components/action_history/action_history.py b/classic/forge/forge/components/action_history/action_history.py index c9a8c8df6d..a096c08dee 100644 --- a/classic/forge/forge/components/action_history/action_history.py +++ b/classic/forge/forge/components/action_history/action_history.py @@ -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: diff --git a/classic/original_autogpt/autogpt/agents/agent.py b/classic/original_autogpt/autogpt/agents/agent.py index 03f944501b..42632a7912 100644 --- a/classic/original_autogpt/autogpt/agents/agent.py +++ b/classic/original_autogpt/autogpt/agents/agent.py @@ -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