Python: align Foundry hosting response conversion - #7965
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Aligns Foundry hosting response conversion with JSON-safe serialization and preserves shell execution metadata.
Changes:
- Unifies argument/result serialization and preserves falsey values.
- Consolidates input/output item conversion logic.
- Adds regression tests for serialization, MCP output, and shell limits.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
_responses.py |
Updates response serialization and item conversion. |
test_responses.py |
Adds conversion and round-trip coverage. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): e5c2c5fe9824
Model: gpt-5.6-sol
Overview
The PR successfully centralizes JSON-safe conversion, preserves falsey function results and shell limits, and adds focused parity tests for correlated and uncorrelated MCP output. The shared conversion path also preserves approval storage and the specialized OutputItem cases. Two MCP output boundaries remain: arbitrary values permitted by the public Any contract can now fail serialization, and uncorrelated mappings with a text field can lose accompanying structured data.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (2 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py
Keep dataclass and to_dict conversion while encoding unsupported result values via their string representation. Only unwrap recognized MCP text content so structured mappings retain every field. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Resolve Foundry response conversion conflicts while retaining upstream call-id validation and cache-write usage support. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
MAF Automated Review — Iteration 2
Result: No findings
Scope: 22 net-new commit(s): dc7714295fff, 52a376453994, 34d1ac70b2fc, 178f365dc69e, 44c8cf6a2012, 6ed829cf713e, f7e78c689bb9, 341d0ec35bbc, 947d933f2385, de02975ee606, 6d532cf77e26, edfe115ea06b, 1aca2a95e3b9, 4c0bff8b77d5, a617392cc79b, 5996105a1bf2, d2a934d53530, 018dea570b84, 11d628d60ff2, 6a0773ba2180, 1a40758bfa86, a49a59772cf6
Model: gpt-5.6-sol
Overview
The change centralizes JSON-safe conversion, preserves falsey values and structured MCP output, retains shell limits, and delegates shared output parsing to the input converter. Focused tests cover unsupported leaf values, structured mappings, replay metadata, MCP correlation, and streaming lifecycle behavior. No new Critical, High, or Medium issue remains after reconciling the implementation with those guards and the supplied prior feedback.
Reviewed the supplied incremental change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Fall back to a JSON-encoded string when structured result encoding raises TypeError or ValueError, while preserving arbitrary user-code exceptions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: aab30b40-e3c5-41b4-84c1-1b27d7ddf351
Motivation & Context
Foundry hosting converted some structured arguments and results with Python string representations, which can produce invalid JSON on the wire and erased falsey function results. MCP result serialization also differed depending on whether a matching call was still active, while supported shell execution limits were dropped during response conversion. These inconsistencies make replayed items and hosted response events less faithful to Agent Framework
Contentvalues.Description & Review Guide
0andFalsesurvive conversion, MCP outputs are consistent, shell settings round-trip through Agent Server 2.1 models, and the duplicated parser logic is reduced without changing public APIs or dependencies.Related Issue
N/A — focused follow-up cleanup.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.