Repository navigation
Python: Send empty text for GitHubCopilotAgent tool results without text - #10272
Aditya Kumar (Aditya-XR) wants to merge 1 commit into
Conversation
The Copilot tool adapter fell back to str(result) when a tool produced no
text. Since tool results became lists of Content items, that fallback sends
the list repr ("[<agent_framework._types.Content object at 0x...>]") to the
model for tools that return None, an empty string, or only rich content.
Send the joined text as is, so these tools report an empty result like the
Copilot SDK does for a handler that returns None.
|
/review |
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (1 commit(s)): f9103266c669
Model: gpt-5.6-sol
Overview
The PR removes an obsolete fallback that stringified the list[Content] returned by FunctionTool.invoke, and instead forwards the joined text or an empty string. The new parametrized test covers None, empty-string, and rich-only returns, while the unchanged warning and error paths preserve existing guardrails. Empty text is consistent with the SDK normalization path and the Claude provider adapter, and no publishable Critical, High, or Medium issue was established.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Motivation & Context
When a function tool given to
GitHubCopilotAgentproduces no text, the model receives the repr of a Python list as the tool result, for example[<agent_framework._types.Content object at 0x77287488b230>]. This happens when the tool returnsNone, an empty string, or only rich content such as an image.The tool adapter falls back to
str(result)when there is no text. That was correct whileFunctionTool.invokereturned a string, but since #4331 it returns a list ofContentitems, so the fallback now produces the list repr.Description & Review Guide
What are the major changes?
The adapter in
_tool_to_copilot_toolnow sends the joined text as is:A new parametrized test,
test_tool_handler_returns_empty_text_when_tool_returns_no_text, covers a tool that returnsNone,""and only an image. Without the fix all three cases fail, becausetext_result_for_llmis theContentlist repr.What is the impact of these changes?
Tools without a text result now report an empty string to the model instead of a repr with a memory address. Tools that return text are unchanged. For a tool that returns only rich content, the existing "does not support rich tool content" warning is still logged and the result text is empty.
What do you want reviewers to focus on?
An empty string is what the Copilot SDK sends for a handler that returns
None(copilot.tools._normalize_result), and whatClaudeAgentsends in the same case, so I used the same value here.Related Issue
Fixes #10271
This is a one-line correction of a leftover
str(result)fallback from #4331, so I opened it together with the issue.AI Assistance
AI assistance details: I used Claude Code as an assistant to help find the bug and to draft the fix, the test, the linked issue and this description. I did the final review myself: I read and understood every change, checked the repro and test results, and made the final decisions on what to submit.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.