Python: Fix MangenticAgentExecutor producing repr str for tool call content#2566
Merged
moonbox3 merged 1 commit intomicrosoft:mainfrom Dec 2, 2025
Merged
Python: Fix MangenticAgentExecutor producing repr str for tool call content#2566moonbox3 merged 1 commit intomicrosoft:mainfrom
moonbox3 merged 1 commit intomicrosoft:mainfrom
Conversation
Member
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where MagenticAgentExecutor was producing garbage repr output when agent responses contained only tool calls (FunctionCallContent) without text content. The fix replaces str(last) fallback with an empty string "", aligning with the established pattern used throughout the codebase.
Key Changes:
- Changed fallback from
str(last)to""whenChatMessage.textis empty - Applied the fix consistently in both the core workflow and DevUI mapper
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
python/packages/core/agent_framework/_workflows/_magentic.py |
Fixed _invoke_agent method to use empty string instead of repr output when message has no text content |
python/packages/devui/agent_framework_devui/_mapper.py |
Fixed _convert_workflow_event method to use empty string instead of repr output for orchestrator messages without text |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
dmytrostruk
approved these changes
Dec 2, 2025
eavanvalkenburg
approved these changes
Dec 2, 2025
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 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
When an agent's response contains only
FunctionCallContent(tool calls) without text content,ChatMessage.textreturns an empty string. The codetext = last.text or str(last)evaluated the fallbackstr(last), which produced garbage repr output like<agent_framework._types.ChatMessage object at 0x...>.Changed to
text = last.text or ""to match the existing pattern used elsewhere in the SDK. Thecontentslist still contains theFunctionCallContentitems for consumers who need them.Description
Contribution Checklist