Skip to content

Python: Enhance _OutputItemTracker to prevent duplicate function call streaming - #7486

Open
Chinedum Echeta (cecheta) wants to merge 3 commits into
microsoft:mainfrom
cecheta:tool-fix-streaming
Open

Python: Enhance _OutputItemTracker to prevent duplicate function call streaming#7486
Chinedum Echeta (cecheta) wants to merge 3 commits into
microsoft:mainfrom
cecheta:tool-fix-streaming

Conversation

@cecheta

Copy link
Copy Markdown
Member

Motivation & Context

Fixes bug where function call was duplicated when streaming response from declaration-only tool,

Description & Review Guide

When the agent invokes the declaration-only tool, there is a second function call emitted containing just metadata. Both of these tools were being streamed to the user.

Related Issue

Fixes #7485

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.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/foundry_hosting/agent_framework_foundry_hosting
   _responses.py7209486%144–145, 159, 162–163, 213, 228, 290, 349–352, 388–389, 392, 396, 428, 507, 510, 514, 580, 642–643, 999, 1011, 1463–1464, 1468, 1513, 1515, 1517, 1519, 1523, 1531, 1534–1538, 1540, 1550, 1554, 1601–1606, 1610–1611, 1619–1625, 1655–1656, 1658–1659, 1661, 1666, 1674–1675, 1677, 1682–1686, 1688, 1695–1696, 1698–1699, 1705, 1707–1711, 1721, 1727, 1751, 1757, 1763, 1765, 1767–1770, 1778, 1780
TOTAL45637425390% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
9245 36 💤 0 ❌ 0 🔥 2m 34s ⏱️

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 Foundry Hosting streaming bug in the Python implementation where a declaration-only tool invocation can result in a duplicate function_call output item being streamed to the client. The change extends the streaming output-item tracker to recognize and suppress the metadata-only duplicate call, and adds a regression test covering the scenario.

Changes:

  • Track previously-streamed function call call_ids during a streaming response.
  • Suppress streaming of metadata-only duplicate function-call updates for already-seen call_ids.
  • Add a regression test ensuring only one function_call output item is emitted for declaration-only metadata follow-ups.
Show a summary per file
File Description
python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py Adds duplicate-detection logic in _OutputItemTracker to prevent streaming a second metadata-only function call item.
python/packages/foundry_hosting/tests/test_responses.py Adds a regression test reproducing the declaration-only metadata duplication scenario in streaming mode.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

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.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@moonbox3 Evan Mattson (moonbox3) added the hosting Usage: [Issues, PRs], Target: all hosting related solutions label Aug 5, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 9b232bff-6a8c-4b02-addd-89de57a82f6a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hosting Usage: [Issues, PRs], Target: all hosting related solutions python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Duplicate function call in Foundry Hosted agent when streaming

3 participants