Skip to content

Python: Allow OpenAI function results without call IDs - #7928

Open
mikemikimike wants to merge 2 commits into
microsoft:mainfrom
mikemikimike:fix/openai-optional-function-result-call-id
Open

Python: Allow OpenAI function results without call IDs#7928
mikemikimike wants to merge 2 commits into
microsoft:mainfrom
mikemikimike:fix/openai-optional-function-result-call-id

Conversation

@mikemikimike

@mikemikimike mikemikimike commented Aug 28, 2026

Copy link
Copy Markdown

Motivation & Context

The OpenAI Responses API permits function_call_output items without a call_id, but Agent Framework currently requires one when constructing function-result content and serializes an absent value as "call_id": null. This makes adapting OpenAI-compatible SDK payloads unnecessarily difficult.

Description & Review Guide

  • What are the major changes? Content.from_function_result now accepts an omitted call ID, and the OpenAI Responses serializer only includes call_id when one is provided.
  • What is the impact of these changes? Function results without IDs can be represented and sent without a null field; existing function results with IDs retain their current payload.
  • What do you want reviewers to focus on? Please review the optional-field boundary and the unchanged ID-preserving path. The function-calling specification matrix now names this provider scenario and links it to the regression test in packages/openai/tests/openai/test_openai_chat_client.py.
  • Local checks: The OpenAI package's non-integration test suite passes, focused core factory tests pass, Ruff 0.16.3 checks pass, targeted Pyright passes for both changed source files, and both affected packages build successfully.
  • Known environment limitation: The full core test and standard dependency type-checking sweeps require optional mcp, agent-hooks, and related workspace packages that are not installed in this checkout.
  • Review status: This pull request remains a draft for maintainer confirmation of the function-calling contract.

Related Issue

Fixes #7922

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible (the focused core tests and full OpenAI package suite pass; the full core sweep is limited by optional workspace dependencies noted above)
  • 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.

Copilot AI balanced review requested due to automatic review settings August 28, 2026 02:43
@mikemikimike
mikemikimike deployed to github-app-auth August 28, 2026 02:43 — with GitHub Actions Active
@mikemikimike
mikemikimike deployed to github-app-auth August 28, 2026 02:43 — with GitHub Actions Active
@mikemikimike
mikemikimike deployed to github-app-auth August 28, 2026 02:43 — with GitHub Actions Active
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Aug 28, 2026
@mikemikimike
mikemikimike deployed to github-app-auth August 28, 2026 02:43 — with GitHub Actions Active

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

Allows OpenAI Responses API function results to omit call_id instead of serializing it as null.

Changes:

  • Makes Content.from_function_result accept an optional call ID.
  • Conditionally serializes call_id.
  • Adds regression tests for ID-less results.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
python/packages/core/agent_framework/_types.py Makes result call IDs optional.
python/packages/core/tests/core/test_types.py Tests ID-less result construction.
python/packages/openai/agent_framework_openai/_chat_client.py Omits absent IDs from Responses payloads.
python/packages/openai/tests/openai/test_openai_chat_client.py Tests serialization with no call ID.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

assert result["output"] == "Simple result"


def test_prepare_content_for_openai_function_result_without_call_id() -> None:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in commit 69bba19: added the OpenAI function-result-without-call-ID row to docs/specs/004-python-function-calling-loop.md and linked it to test_prepare_content_for_openai_function_result_without_call_id.

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]: OpenAI RAPI no longer requires the call id on a function call result

2 participants