Skip to content

Python: Preserve declaration-only streaming metadata - #7409

Open
eavanvalkenburg wants to merge 2 commits into
microsoft:mainfrom
eavanvalkenburg:python-declaration-only-streaming
Open

Python: Preserve declaration-only streaming metadata#7409
eavanvalkenburg wants to merge 2 commits into
microsoft:mainfrom
eavanvalkenburg:python-declaration-only-streaming

Conversation

@eavanvalkenburg

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

  • What are the major changes?
    • Emit a metadata-only finalized declaration update with arguments=None.
    • Preserve id and user_input_request while function-call chunks are aggregated.
    • Cover split-argument and single-chunk provider streams.
    • Preserve workflow request_info signaling for client-side tools.
  • What is the impact of these changes?
    • Declaration-only arguments appear exactly once in the final response.
    • Streaming consumers still receive the pause/request metadata.
    • Executable and informational function calls are unaffected.
  • What do you want reviewers to focus on?
    • Metadata propagation through Content addition.
    • Raw stream versus finalized response parity.

Related Issue

Fixes #6973

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.py13508393%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, 1952, 2022, 2036, 2039, 2052, 2055, 2078, 2085, 2094, 2098, 2123, 2157, 2225, 2254–2255, 2352, 2380, 2420, 2423, 2480, 2633, 2722, 3201
   _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
TOTAL45864447590% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
9468 34 💤 0 ❌ 0 🔥 2m 43s ⏱️

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 and others added 2 commits July 30, 2026 08:58
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 996ce38 to ae50232 Compare July 30, 2026 06:59
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

3 participants