.NET: fix: Foundry Agents without description in Handoff#5311
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens handoff tool description (“handoffReason”) derivation in the .NET Workflows handoff builder to better support Foundry agents that return empty strings for Description, and to support wrapped agents by retrieving an underlying ChatClientAgent via AIAgent.GetService.
Changes:
- Treat empty/whitespace
AIAgent.DescriptionandAIAgent.Nameas missing when deriving the defaulthandoffReason. - Use
AIAgent.GetService(...)to retrieve an underlyingChatClientAgent(instead of casting the outer agent) to fall back toChatClientAgent.Instructions.
westey-m
approved these changes
Apr 16, 2026
Foundry Agents without a description set will return an empty string (rather than null) for the description. This was breaking the fallback logic for `handoffReason`.
3076066 to
14c8683
Compare
rogerbarreto
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Foundry Agents without a description set will return an empty string (rather than null) for the description. This was breaking the fallback logic for
handoffReason.There was also logic to try to cast the
AIAgenttoChatClientAgentwhich would not work for wrapped agents, e.g. anything usingDelegatingAIAgent, or anyFoundryAgent.Description
AIAgent.DescriptionandAIAgent.Name.AIAgent.GetServicemechanism to get an underlyingChatClientAgentrather than casting the outermostAIAgentinstance.Contribution Checklist
[ ] Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.