Skip to content

Python: Add regression tests for MCP tool result event projection in GitHubCopilotAgent - #6226

Closed
Giles Odigwe (giles17) wants to merge 2 commits into
microsoft:mainfrom
giles17:agent/fix-5897-3
Closed

Python: Add regression tests for MCP tool result event projection in GitHubCopilotAgent#6226
Giles Odigwe (giles17) wants to merge 2 commits into
microsoft:mainfrom
giles17:agent/fix-5897-3

Conversation

@giles17

Copy link
Copy Markdown
Contributor

Motivation and Context

The Python GitHubCopilotAgent already correctly projects MCP tool execution events into FunctionCallContent and FunctionResultContent (fixed in #4734, #4814, #4828), but there was no dedicated test covering the multi-tool-call scenario described in #5897. These tests prevent regression of the projection logic that, when broken, causes models to fabricate timeout errors because tool results appear as opaque content instead of semantically marked function results.

Fixes #5897

Description

Adds a streaming test (test_run_streaming_multiple_tool_calls_with_json_results) that exercises three consecutive MCP tool invocations returning JSON payloads, verifying that each TOOL_EXECUTION_START event is projected as a function_call content item and each TOOL_EXECUTION_COMPLETE event is projected as a function_result content item with the correct call_id, tool name, and result payload. This directly covers the scenario from issue #5897 where successful MCP tool returns were silently dropped as opaque AIContent.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Note: PR autogenerated by giles17's agent

Copilot AI review requested due to automatic review settings May 31, 2026 22:03
@moonbox3 Evan Mattson (moonbox3) added the python Usage: [Issues, PRs], Target: Python label May 31, 2026

@giles17 Giles Odigwe (giles17) left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 4 | Confidence: 96% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach


Automated review by giles17's agents

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

Adds a targeted regression test to ensure GitHubCopilotAgent streaming mode continues to correctly project multiple consecutive MCP tool execution events into semantic function_call / function_result content items (covering the multi-tool-call scenario from #5897).

Changes:

  • Add a new streaming regression test that simulates three consecutive tool calls with JSON string payload results and asserts correct projection (role, content type, call_id, tool name, result).
  • Minor formatting-only updates in a sample harness and a couple of core/test files (no behavior changes).
  • Lockfile metadata tweak for the Copilot SDK specifier string (no effective version change).

Reviewed changes

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

Show a summary per file
File Description
python/uv.lock Minor normalization of the Copilot SDK specifier string in lock metadata.
python/samples/02-agents/harness/harness_research.py Readability-only reformatting of a compound conditional.
python/packages/github_copilot/tests/test_github_copilot_agent.py Adds a regression test for streaming projection across multiple tool calls with JSON results.
python/packages/core/tests/core/test_skills.py Removes unnecessary parentheses in awaited calls (style-only).
python/packages/core/agent_framework/_skills.py String formatting adjustments in tool metadata (no functional change).

@moonbox3

Evan Mattson (moonbox3) commented May 31, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _skills.py8653196%289, 536, 548, 1002, 1017, 1019–1020, 1376–1377, 1389–1390, 1620, 1649, 2112, 2568–2569, 2704, 2709, 2712, 2717, 2744, 2749, 2803, 2812, 2817, 2820, 2825, 2849, 2854, 3096–3097
TOTAL37393435088% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
7452 34 💤 0 ❌ 0 🔥 1m 57s ⏱️

@github-actions github-actions Bot 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.

Automated Code Review

Reviewers: 4 | Confidence: 90% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach


Automated review by giles17's agents

)

Add a streaming test that exercises multiple consecutive MCP tool
invocations with JSON payloads, verifying that TOOL_EXECUTION_START
and TOOL_EXECUTION_COMPLETE events are projected as function_call and
function_result content items with correct call_id, tool name, and
result payload.

Removes unrelated formatting-only changes from prior iteration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@giles17 Giles Odigwe (giles17) left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 4 | Confidence: 96%

✓ Correctness

This PR contains only cosmetic/formatting changes: collapsing multi-line strings onto single lines, removing redundant parentheses around await expressions, reformatting a long conditional, and reordering equivalent version specifiers in uv.lock. All changes are semantically identical to the original code. No correctness issues found.

✓ Security Reliability

This PR contains only cosmetic/formatting changes: collapsing multi-line string literals into single lines, removing redundant parentheses around await expressions, reformatting a long conditional, and reordering semantically-equivalent version specifiers in uv.lock. There are no behavioral, security, or reliability concerns.

✓ Test Coverage

This PR contains exclusively cosmetic/formatting changes: collapsing multi-line strings onto single lines in _skills.py, removing redundant parentheses around await expressions in tests, reformatting a long conditional in a sample file, and reordering version specifiers in uv.lock. There are no behavioral changes whatsoever, so no new test coverage is needed.

✓ Design Approach

This patch does not appear to address the Python-side GitHub Copilot tool-event issue it was meant to fix. The only changes here are formatting-only edits in core/_skills.py, tests that just remove redundant parentheses, a formatting tweak in a sample harness, and a non-functional dependency-specifier reorder in uv.lock. Meanwhile, the actual Python Copilot agent already handles TOL_EXECUTION_START and TOL_EXECUTION_COMPLETE by emitting function-call and function-result content in python/packages/github_copilot/agent_framework_github_copilot/_agent.py:642-678, so this PR's current design leaves the real issue surface untouched.


Automated review by giles17's agents

Comment thread python/packages/core/agent_framework/_skills.py
…ubCopilotAgent silently drops MCP tool result events — projected as opaque AIContent instead of FunctionResultContent, causing models to fabricate timeout errors

@giles17 Giles Odigwe (giles17) left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 4 | Confidence: 95% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach


Automated review by giles17's agents

@giles17
Giles Odigwe (giles17) marked this pull request as draft May 31, 2026 22:49
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

3 participants