Python: fix: always include output in function call result message#2414
Merged
moonbox3 merged 1 commit intomicrosoft:mainfrom Nov 25, 2025
Merged
Conversation
This follows the official OpenAI API schema
eavanvalkenburg
approved these changes
Nov 24, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the "output" field was conditionally added to function call result messages only when the result value was truthy. This caused API errors when function calls returned falsy values (like empty lists, None, False, etc.), as the OpenAI Responses API requires the "output" field to always be present.
- Changed the conditional logic to always include the "output" field in function call result messages
- The fix applies to both
OpenAIResponsesClientandAzureOpenAIResponsesClient(which inherits from the base class) - The
prepare_function_call_resultsfunction properly handles all falsy values by JSON-serializing them
Member
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
moonbox3
approved these changes
Nov 25, 2025
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 2026
…#2414) This follows the official OpenAI API schema
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
Previously the "output" field was only appended to function call result message in
AzureOpenAIResponsesClientonly if it was a 'truthy' value.This meant that if the result of the tool call was an empty list (treated as 'falsy' value by python), the message was missing an output field, which was resulting in a following
BadRequesterror coming from OpenAI api:ServiceResponseException: <class 'agent_framework.azure._responses_client.AzureOpenAIResponsesClient'> service failed to complete the prompt: Error code: 400 - {'error': {'message': "Missing required parameter: 'input[3].output'.", 'type': 'invalid_request_error', 'param': 'input[3].output', 'code': 'missing_required_parameter'}}.Screenshot below showcases the error (I added a simple log to prints
content.result.The error comes from the fact that to according OpenAI Responses api schema, the "output" field is required as part of Function call tool output input message (link to schema)
The error can be simply reproduced by using a dummy tool that always returns empty list or None.
Description
This pull request simply always appends an "output" field to the function call output message, regardless whether the result of function call is truthy or not. I also made the mock tool and tested that the serialization function
prepare_function_call_resultsis able to deal with None value as well as other falsy values.Contribution Checklist