Skip to content

Python: Preserve declaration-only streaming metadata - #7409

Merged
eavanvalkenburg merged 3 commits into
microsoft:mainfrom
eavanvalkenburg:python-declaration-only-streaming
Jul 30, 2026
Merged

Python: Preserve declaration-only streaming metadata#7409
eavanvalkenburg merged 3 commits into
microsoft:mainfrom
eavanvalkenburg:python-declaration-only-streaming

Conversation

@eavanvalkenburg

@eavanvalkenburg eavanvalkenburg commented Jul 29, 2026

Copy link
Copy Markdown
Member

Motivation & Context

Streaming declaration-only calls currently replay the finalized arguments after the provider already streamed
them, causing the final response to concatenate the arguments twice.

Description & Review Guide

Related Issue

Fixes #6973

Depends on #7407 and #7408; merge this PR last.

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 is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI review requested due to automatic review settings July 29, 2026 20:11
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Jul 29, 2026
@eavanvalkenburg
eavanvalkenburg marked this pull request as ready for review July 29, 2026 20:12
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _tools.py13758393%230–231, 408, 410, 423, 448–450, 458, 476, 490, 497, 504, 527, 529, 536, 544, 679, 713–715, 718–720, 722, 728, 779–781, 806, 832, 836, 874–876, 880, 1053, 1065, 1072–1075, 1096, 1104, 1118–1120, 1490, 1573, 1601, 1623, 1675–1676, 1733, 1780, 1787–1788, 1878, 1940–1941, 1971, 2067, 2081, 2084, 2097, 2100, 2123, 2130, 2139, 2143, 2168, 2202, 2270, 2299–2300, 2397, 2425, 2465, 2468, 2525, 2678, 2767, 3256
   _types.py12329692%61, 70–71, 125, 134, 153, 155, 159, 163, 165, 167, 169, 187, 191, 217, 239, 244, 249, 253, 283, 709–710, 891–892, 1350, 1425, 1460, 1480, 1490, 1684–1686, 1971–1976, 2001, 2056, 2061, 2071, 2079, 2086–2090, 2108, 2181, 2194, 2199, 2312, 2335, 2596, 2620, 2719, 2900–2901, 3003, 3232, 3285, 3304, 3343, 3354, 3356–3360, 3362, 3365–3373, 3383, 3472, 3609, 3614, 3619, 3624, 3628, 3714–3716, 3745, 3833–3837
TOTAL46024447890% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
9513 34 💤 0 ❌ 0 🔥 2m 30s ⏱️

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.

Pull request overview

Fixes a Python streaming edge case where declaration-only tool calls could end up with duplicated arguments in the finalized response by ensuring the function-invocation layer emits metadata-only updates while preserving control metadata during content aggregation.

Changes:

  • Emit a metadata-only finalized declaration update (arguments=None) during streaming so provider-streamed argument chunks aren’t replayed/duplicated.
  • Preserve id and user_input_request when aggregating function_call Content instances.
  • Add regression tests for split-argument vs single-chunk streams, and document the behavior in the Python agent conventions/spec.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
python/packages/core/agent_framework/_tools.py Emits metadata-only function_call streaming updates to avoid replaying streamed arguments.
python/packages/core/agent_framework/_types.py Propagates id and user_input_request through function_call content aggregation.
python/packages/core/tests/core/test_function_invocation_logic.py Adds streaming regression coverage for declaration-only calls (split and single-chunk arguments).
python/packages/core/tests/core/test_types.py Adds unit coverage ensuring metadata-only follow-ups preserve control metadata without altering arguments.
python/packages/core/AGENTS.md Documents the declaration-only streaming behavior and metadata-only follow-up semantics.
docs/specs/004-python-function-calling-loop.md Updates spec/test matrix to reflect the new covered regression scenario for #6973.

@eavanvalkenburg
eavanvalkenburg added this pull request to the merge queue Jul 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jul 30, 2026
eavanvalkenburg and others added 3 commits July 30, 2026 10:44
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1ee1d250-d1e2-4c6f-8c36-aae0d94fe7a1
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1ee1d250-d1e2-4c6f-8c36-aae0d94fe7a1
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1ee1d250-d1e2-4c6f-8c36-aae0d94fe7a1
@eavanvalkenburg
eavanvalkenburg force-pushed the python-declaration-only-streaming branch from 956920c to fcc7c4f Compare July 30, 2026 08:44
@eavanvalkenburg
eavanvalkenburg added this pull request to the merge queue Jul 30, 2026
Merged via the queue into microsoft:main with commit 99dcf3c Jul 30, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Duplicate arguments in declaration-only function call when streamed

4 participants