Repository navigation
Python: Description not set in OrchestrationHandoffs when adding agent by name - #13122
Conversation
|
@microsoft-github-policy-service agree company="GoTo" |
| 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 ""), |
There was a problem hiding this comment.
Hi, thank you for your contributions! But this change doesn't alter the logic. The result would stay the same.
There was a problem hiding this comment.
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)
|
Hi, could you give more context on what the issue is? If agent names are given without providing a handoff description, then the description will be empty. If agent instances are given then the framework will try to get the descriptions from the agent instances. However, since the description property is not required, it may fall back to an empty string. |
|
You can look at the added test case
Yes, I think that part is correct. This issue I'm having is basically the opposite: agent names are given (as str) with a handoff description. This is from the sample: But the description ends up being empty in the function definition. |
| assert handoff_description == "Description Agent A" | ||
|
|
||
|
|
||
| def test_orchestration_handoff_add_with_description(): |
There was a problem hiding this comment.
This is working correctly in main/released version
| assert handoff_description == "Description from Agent B to Agent A" | ||
|
|
||
|
|
||
| def test_orchestration_handoff_add_by_name_with_description(): |
There was a problem hiding this comment.
In main/released version, handoff_description == ''
|
I've added review comments into the PR to maybe help the discussion. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The fix is covered by targeted tests and no blocking issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Fixes OrchestrationHandoffs.add so explicit descriptions are preserved when agents are provided by name.
Changes:
- Corrected conditional-expression precedence.
- Added regression tests for handoff description handling.
| File | Description |
|---|---|
python/tests/unit/agents/orchestration/test_handoff.py |
Adds regression coverage for description behavior. |
python/semantic_kernel/agents/orchestration/handoffs.py |
Preserves supplied descriptions for name-based handoffs. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Motivation and Context
When setting an OrchestrationHandoffs configuration using agent's name instead of the Agent instances, the description field is not taken into account.
This causes the description to not be part of the function definition sent to the LLM.
Description
Fix Python construct used when generating the description to be used.
Contribution Checklist