diff --git a/python/samples/getting_started_with_agents/azure_ai_agent/step3_azure_ai_agent_group_chat.py b/python/samples/getting_started_with_agents/azure_ai_agent/step3_azure_ai_agent_group_chat.py index 064fdd6415cd..3ec88593421e 100644 --- a/python/samples/getting_started_with_agents/azure_ai_agent/step3_azure_ai_agent_group_chat.py +++ b/python/samples/getting_started_with_agents/azure_ai_agent/step3_azure_ai_agent_group_chat.py @@ -21,7 +21,12 @@ class ApprovalTerminationStrategy(TerminationStrategy): async def should_agent_terminate(self, agent, history): """Check if the agent should terminate.""" - return "approved" in history[-1].content.lower() + resp = history[-1].content.lower() + + # The agent would sometimes respond with simple "Not approved," which + # would trigger the termination. Even if the prompt clearly states not + # to use the word, it fails on 4o. This is a simple check to avoid that. + return "approved" in resp and not "not approved" in resp REVIEWER_NAME = "ArtDirector"