Skip to content

Python: Description not set in OrchestrationHandoffs when adding agent by name - #13122

Open
Audric Schiltknecht (audricschiltknecht) wants to merge 2 commits into
microsoft:mainfrom
audricschiltknecht:fix/python-description-handoff-by-name
Open

Audric Schiltknecht (audricschiltknecht) wants to merge 2 commits into
microsoft:mainfrom
audricschiltknecht:fix/python-description-handoff-by-name

Conversation

@audricschiltknecht

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

Copy link
Copy Markdown

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

@moonbox3 Evan Mattson (moonbox3) added the python Pull requests for the Python Semantic Kernel label Sep 15, 2025
@audricschiltknecht

Copy link
Copy Markdown
Author

@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 ""),

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)

@TaoChenOSU

Copy link
Copy Markdown
Contributor

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.

@audricschiltknecht

Audric Schiltknecht (audricschiltknecht) commented Sep 15, 2025 •

Copy link
Copy Markdown
Author

You can look at the added test case test_orchestration_handoff_add_by_name_with_description.

If agent names are given without providing a handoff description, then the description will be empty.

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():

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

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 == ''

@audricschiltknecht

Copy link
Copy Markdown
Author

I've added review comments into the PR to maybe help the discussion.

Copilot AI left a comment

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.

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.

This branch had an error being deployed

1 failed deployment
github-app-auth — 4e007bd5 Deployed Sep 28, 2026 by eavanvalkenburg via add_label #29079
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests for the Python Semantic Kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants