Skip to content

fix(python): forward binary tool results in HandlePendingToolCall RPC - #1821

Merged
SteveSandersonMS merged 2 commits into
github:mainfrom
syf2211:fix/1644-forward-binary-tool-results
Jul 31, 2026
Merged

fix(python): forward binary tool results in HandlePendingToolCall RPC#1821
SteveSandersonMS merged 2 commits into
github:mainfrom
syf2211:fix/1644-forward-binary-tool-results

Conversation

@syf2211

@syf2211 syf2211 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

When a Python tool handler returns a ToolResult with binary_results_for_llm (e.g. base64 image data) or session_log, those fields were dropped while building the ExternalToolTextResultForLlm payload in _execute_tool_and_respond. The model only received text fields, so image tool outputs appeared unavailable.

Motivation

Fixes #1644. Users building agents with image-returning tools saw the model report it could not view images, even though direct blob attachments worked.

Changes

  • Add tool_result_to_external_tool_text_result_for_llm() in python/copilot/tools.py to map ToolResultExternalToolTextResultForLlm, including binary result type enum conversion.
  • Use the helper in CopilotSession._execute_tool_and_respond instead of an inline constructor that omitted binary_results_for_llm and session_log.
  • Add unit tests covering binary forwarding and the no-binary case.

Tests

cd python && uv run pytest test_tools.py::TestToolResultToExternalToolTextResultForLlm -q
cd python && uv run ruff check copilot/tools.py copilot/session.py test_tools.py
  • 2 passed
  • ruff: All checks passed

Notes

  • Scope is Python SDK only; Node passes the full result object through RPC already.
  • Composer-2.5 code review: APPROVE

@syf2211
syf2211 requested a review from a team as a code owner June 28, 2026 04:04
syf2211 and others added 2 commits July 31, 2026 14:56
ToolResult.binary_results_for_llm and session_log were dropped when
building ExternalToolTextResultForLlm in _execute_tool_and_respond,
so image/binary tool outputs never reached the model.

Fixes github#1644
…ingToolCall RPC

ToolResult.BinaryResultsForLLM and SessionLog were dropped when building
ExternalToolTextResultForLlm in executeToolAndRespond, mirroring the same
bug fixed in Python by this PR. Binary tool outputs (e.g. images) returned
by Go tool handlers never reached the model.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@SteveSandersonMS
SteveSandersonMS force-pushed the fix/1644-forward-binary-tool-results branch from bb98cdb to 2c7c733 Compare July 31, 2026 15:00

@SteveSandersonMS SteveSandersonMS 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.

Thanks @syf2211!

@SteveSandersonMS
SteveSandersonMS added this pull request to the merge queue Jul 31, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 31, 2026
@SteveSandersonMS
SteveSandersonMS added this pull request to the merge queue Jul 31, 2026
Merged via the queue into github:main with commit 5e09c68 Jul 31, 2026
43 checks passed
@mohamadhosenzademohamad-oss

Copy link
Copy Markdown

cd python && uv run pytest test_tools.py::TestToolResultToExternalToolTextResultForLlm -q
cd python && uv run ruff check copilot/tools.py copilot/session.py test_tools.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Binary tool results not passed to ExternalToolTextResultForLlm

3 participants