Skip to content

Commit 206655a

Browse files
nmoellercrickmanmoonbox3
authored
Python: Add check for not approved and approved for Agent Sample (#12316)
### Motivation and Context I was having a Demo with the Agents, and found that `step06_chat_completion_agent_group_chat.py` sample always terminated after one iteration. The Reviewer Agent answered "not approved", which also triggered the `Termination Strategy`, due to the fact that the word `approved` is also in `not approved`. To only trigger when there is a real approval I added a check if the answer is `approved` **and** the answer also don't include `not approve` ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Chris <66376200+crickman@users.noreply.github.com> Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
1 parent 6ab3489 commit 206655a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

python/samples/getting_started_with_agents/chat_completion/step06_chat_completion_agent_group_chat.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class ApprovalTerminationStrategy(TerminationStrategy):
3434

3535
async def should_agent_terminate(self, agent, history):
3636
"""Check if the agent should terminate."""
37-
return "approved" in history[-1].content.lower()
37+
last_message = history[-1].content.lower()
38+
return "approved" in last_message and "not approved" not in last_message
3839

3940

4041
REVIEWER_NAME = "ArtDirector"

0 commit comments

Comments
 (0)