Python: fix: include status field on function_call and function_call_output items#4703
Closed
LEDazzio01 wants to merge 1 commit intomicrosoft:mainfrom
Closed
Conversation
… items Fixes microsoft#4701. The _prepare_content_for_openai method had two bugs: 1. function_call items set status to None unconditionally, causing API rejections for AG-UI client-side tools where additional_properties did not carry a status value. 2. function_call_output items omitted the status field entirely. Changes: - function_call: resolve status from additional_properties, falling back to 'completed' when absent or None. - function_call_output: always include status 'completed'. - Added 4 unit tests covering both branches.
status field on function_call and function_call_output itemsstatus field on function_call and function_call_output items
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes serialization of tool-call history for the OpenAI Responses API by ensuring status is always present (and never null) on function_call and function_call_output items, preventing 400s when replaying conversation history (notably for AG-UI client-side tools).
Changes:
- Default
function_call.statusto"completed"when missing/None, while preserving an explicit status if provided. - Always include
"status": "completed"onfunction_call_outputitems. - Add unit tests covering the status behavior for both item types (including
Nonefunction result output).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
python/packages/core/agent_framework/openai/_responses_client.py |
Ensures Responses-API tool-call items always include a valid status field (function_call default/preserve; function_call_output always completed). |
python/packages/core/tests/openai/test_openai_responses_client.py |
Adds focused unit tests validating status handling for tool-call serialization. |
You can also share your feedback on Copilot code review. Take the survey.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Fixes #4701.
When replaying conversation history that includes tool calls through the Responses API, the
_prepare_content_for_openaimethod produced items that violated the API schema:function_callitems set"status": Noneunconditionally. For AG-UI client-side tools whereadditional_propertiesdoes not carry an explicitstatus, this resulted innullbeing sent to the API, causing a400 Bad Request.function_call_outputitems omitted thestatusfield entirely, also causing API rejections.Changes
_responses_client.pyfunction_call: Resolvestatusfromcontent.additional_propertieswhen available, falling back to"completed"when absent orNone.function_call_output: Always include"status": "completed".test_openai_responses_client.pyAdded 4 unit tests:
test_prepare_content_function_call_defaults_status_to_completed— verifies default fallbacktest_prepare_content_function_call_preserves_explicit_status— verifies explicit status is preservedtest_prepare_content_function_result_includes_status_completed— verifies function_call_output always has statustest_prepare_content_function_result_none_result— verifies None result maps to empty string with status