Python: Align OpenAI parser conversions - #7964
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Aligns Python OpenAI conversions with provider wire formats and response metadata.
Changes:
- Preserves supported falsey outputs and zero-valued usage details.
- Omits unsupported Chat Completions content.
- Orders embeddings by provider indexes and adds regression tests.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
_chat_client.py |
Updates function-result output handling. |
_chat_completion_client.py |
Filters unsupported content and preserves zero usage values. |
_embedding_client.py |
Sorts embeddings by response index. |
test_openai_chat_client.py |
Tests falsey function outputs. |
test_openai_chat_completion_client.py |
Tests omission and usage conversions. |
test_openai_embedding_client.py |
Tests indexed embedding ordering. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): be809084dc76
Model: gpt-5.6-sol
Overview
The PR improves conversion fidelity by preserving SDK-supported falsey outputs, retaining explicit zero usage details, omitting unsupported Chat Completions content, and ordering embeddings by provider index, with focused regression coverage for each path. The remaining compatibility risk is that the broader falsey-value check also passes arbitrary deserialized values through to an OpenAI field that accepts only strings or rich-content lists.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (1 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: python/packages/openai/agent_framework_openai/_chat_client.py
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
MAF Automated Review — Iteration 2
Result: No findings
Scope: 1 net-new commit(s): dd765cd2e6c6
Model: gpt-5.6-sol
Overview
This incremental update addresses the prior function-output finding by preserving supported string and list values while serializing other non-None values with the same json.dumps(default=str) pattern used by the framework's canonical function-result constructor. The added tests cover the previously problematic falsey values False, 0, and {} as well as preserving "" and []. No Critical, High, or Medium issue remains in the supplied incremental diff.
Reviewed the supplied incremental change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: aad873ba-4f58-4be2-ad55-720795157704
Motivation & Context
The Python OpenAI clients still had a few conversion paths that conflated valid falsey values with missing values, emitted Agent Framework's internal content representation into Chat Completions requests, or assumed embedding responses arrived in input order. These mismatches could lose provider data, produce invalid request content, or associate an embedding with the wrong input.
Description & Review Guide
Related Issue
N/A — follow-up from the Responses conversion consistency sweep
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.