Skip to content

Python: fix: include status field on function_call and function_call_output items#4703

Closed
LEDazzio01 wants to merge 1 commit intomicrosoft:mainfrom
LEDazzio01:fix/4701-responses-api-missing-status-field
Closed

Python: fix: include status field on function_call and function_call_output items#4703
LEDazzio01 wants to merge 1 commit intomicrosoft:mainfrom
LEDazzio01:fix/4701-responses-api-missing-status-field

Conversation

@LEDazzio01
Copy link
Contributor

Motivation and Context

Fixes #4701.

When replaying conversation history that includes tool calls through the Responses API, the _prepare_content_for_openai method produced items that violated the API schema:

  1. function_call items set "status": None unconditionally. For AG-UI client-side tools where additional_properties does not carry an explicit status, this resulted in null being sent to the API, causing a 400 Bad Request.
  2. function_call_output items omitted the status field entirely, also causing API rejections.

Changes

_responses_client.py

  • function_call: Resolve status from content.additional_properties when available, falling back to "completed" when absent or None.
  • function_call_output: Always include "status": "completed".

test_openai_responses_client.py

Added 4 unit tests:

  • test_prepare_content_function_call_defaults_status_to_completed — verifies default fallback
  • test_prepare_content_function_call_preserves_explicit_status — verifies explicit status is preserved
  • test_prepare_content_function_result_includes_status_completed — verifies function_call_output always has status
  • test_prepare_content_function_result_none_result — verifies None result maps to empty string with status

… 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.
Copilot AI review requested due to automatic review settings March 14, 2026 17:10
@github-actions github-actions bot changed the title fix: include status field on function_call and function_call_output items Python: fix: include status field on function_call and function_call_output items Mar 14, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.status to "completed" when missing/None, while preserving an explicit status if provided.
  • Always include "status": "completed" on function_call_output items.
  • Add unit tests covering the status behavior for both item types (including None function 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.

@LEDazzio01
Copy link
Contributor Author

Closing this in favor of #4704 by @ltwlf, who originally reported the issue and has a more comprehensive fix that also includes filename passthrough for media parts. Thanks for the great catch and fix, @ltwlf! 🙌

@LEDazzio01 LEDazzio01 closed this Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Responses API: missing status field on function_call / function_call_output items

3 participants