Skip to content

Python: Handle tuples in function tool results - #9679

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
ssccinng:openfix/cfb0bcfb-2091-44cf-9b15-616ae191218b
Nov 2, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
ssccinng:openfix/cfb0bcfb-2091-44cf-9b15-616ae191218b

Conversation

@ssccinng

@ssccinng ssccinng commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Motivation & Context

Tuple-valued function tool results should retain their structured values, including Content objects and Pydantic models, instead of being converted into string representations.

Description & Review Guide

  • Handle tuples consistently with lists when parsing and normalizing function tool results.
  • Preserve coverage for structured content and nested results, and narrow optional text values before JSON parsing in the regression tests.
  • Integrate the current target branch while preserving the original contribution and upstream changes.

Validation coverage: the configured test and sample type checks, core source checks, focused tool tests, formatting, lint, and package builds passed on Python 3.11, 3.12, and 3.13 with the pinned dependencies and tools.

Validation: The affected checks fail on the previously published commit and pass after the update. The listed validation commands passed. The same configured checks also passed with Python 3.11.

Related Issue

Fixes #9488.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Implementation, regression coverage, and review were AI-assisted.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or documents the applicable exception
  • This is not a breaking change.

Copilot AI balanced review requested due to automatic review settings November 1, 2026 15:56

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.

🟢 Approval recommended

The tuple-handling changes have no active review issues.

No open issues 🎉

What changed in this PR

This PR addresses #9488 by making Python function tool results handle tuples consistently with lists, preserving rich Content objects and structured Pydantic model values.

Changes:

  • Extend result parsing and recursive JSON normalization to support tuples.
  • Add regression tests for rich content, mixed values, nested model tuples, and empty tuples, with text type checks before JSON parsing.
File Description
python/​packages/​core/​tests/​core/​test_types.py Add regression coverage for tuple serialization and content preservation.
python/​packages/​core/​agent_framework/​_tools.py Handle tuples alongside lists in result parsing and normalization.

Review effort: Balanced

Merged via the queue into microsoft:main with commit c68fe30 Nov 2, 2026
51 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — c005ad73 Deployed Nov 1, 2026 by ssccinng via add_label #26806
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: FunctionTool.parse_result and _make_dumpable do not handle tuples (corrupts rich Content and Pydantic models)

3 participants