Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/semantic_kernel/agents/orchestration/handoffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def add(self, source_agent: str | Agent, target_agent: str | Agent, description:
return self._add(
source_agent=source_agent if isinstance(source_agent, str) else source_agent.name,
target_agent=target_agent if isinstance(target_agent, str) else target_agent.name,
description=description or target_agent.description or "" if isinstance(target_agent, Agent) else "",
description=description or (target_agent.description or "" if isinstance(target_agent, Agent) else ""),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thank you for your contributions! But this change doesn't alter the logic. The result would stay the same.

@audricschiltknecht Audric Schiltknecht (audricschiltknecht) Sep 15, 2025 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I thought too! But from testing, it seems the else part of the statement has priority from the left part of the or expression (which I honestly don't understand why)

)

def add_many(self, source_agent: str | Agent, target_agents: list[str | Agent] | AgentHandoffs) -> "Self":
Expand Down
45 changes: 43 additions & 2 deletions python/tests/unit/agents/orchestration/test_handoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ def test_orchestration_handoff_add():
agent_a = MockAgent()
agent_b = MockAgent()

agent_a.description = "Description Agent A"
agent_b.description = "Description Agent B"

orchestration_handoffs = OrchestrationHandoffs().add(agent_a, agent_b).add(agent_b, agent_a)

assert isinstance(orchestration_handoffs, OrchestrationHandoffs)
Expand All @@ -272,10 +275,48 @@ def test_orchestration_handoff_add():
assert len(orchestration_handoffs[agent_b.name]) == 1
for handoff_agent_name, handoff_description in orchestration_handoffs[agent_a.name].items():
assert handoff_agent_name == agent_b.name
assert handoff_description == ""
assert handoff_description == "Description Agent B"
for handoff_agent_name, handoff_description in orchestration_handoffs[agent_b.name].items():
assert handoff_agent_name == agent_a.name
assert handoff_description == ""
assert handoff_description == "Description Agent A"


def test_orchestration_handoff_add_with_description():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working correctly in main/released version

"""Test the add method of the OrchestrationHandoffs."""
agent_a = MockAgent()
agent_b = MockAgent()

orchestration_handoffs = (
OrchestrationHandoffs()
.add(agent_a, agent_b, "Description from Agent A to Agent B")
.add(agent_b, agent_a, "Description from Agent B to Agent A")
)

for handoff_agent_name, handoff_description in orchestration_handoffs[agent_a.name].items():
assert handoff_agent_name == agent_b.name
assert handoff_description == "Description from Agent A to Agent B"
for handoff_agent_name, handoff_description in orchestration_handoffs[agent_b.name].items():
assert handoff_agent_name == agent_a.name
assert handoff_description == "Description from Agent B to Agent A"


def test_orchestration_handoff_add_by_name_with_description():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In main/released version, handoff_description == ''

"""Test the add method of the OrchestrationHandoffs."""
agent_a = MockAgent()
agent_b = MockAgent()

orchestration_handoffs = (
OrchestrationHandoffs()
.add(agent_a.name, agent_b.name, "Description from Agent A to Agent B")
.add(agent_b.name, agent_a.name, "Description from Agent B to Agent A")
)

for handoff_agent_name, handoff_description in orchestration_handoffs[agent_a.name].items():
assert handoff_agent_name == agent_b.name
assert handoff_description == "Description from Agent A to Agent B"
for handoff_agent_name, handoff_description in orchestration_handoffs[agent_b.name].items():
assert handoff_agent_name == agent_a.name
assert handoff_description == "Description from Agent B to Agent A"


def test_orchestration_handoff_add_many():
Expand Down
Loading