fix(adk): serialize nil FunctionCall.Args as {} not null for OpenAI adapters (#2851) - #2856
Closed
boxcee-interview wants to merge 1 commit into
Closed
boxcee-interview wants to merge 1 commit into
boxcee-interview wants to merge 1 commit into
Conversation
…dapters (kagent-dev#2851) Signed-off-by: Moritz Schmitz von Hülst <[email protected]>
Contributor
|
This is a duplicate of #2852, pls check for existing PRs before opening a new one next time |
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.
Closes #2851
What was wrong
A zero-argument tool call succeeds in one task, then fails on the follow-up task after history is reloaded. Persistence drops empty function-call args (
FunctionCall.Argsisjson:"args,omitempty"), so a reloaded call carries a nilArgsmap. The OpenAI chat-completions and Responses adapters then serialized that nil map as the string"null"instead of"{}". Object-validating backends (oMLX/ollama) reject it with HTTP 422.What the fix does
Coerce a nil
Argsmap to an empty map before marshaling, in the two OpenAI adapters that serialize function-call arguments:go/adk/pkg/models/openai_adk.go(chat completions)go/adk/pkg/models/openai_responses.go(Responses API)This mirrors the identical nil-to-empty coercion already present in the Bedrock adapter (
bedrock.go:686). Added two regression tests (one per adapter) asserting a nil-args call serializes to a JSON object, notnull.How to Test
Docker,
golang:1.27, module rootgo/:Both tests PASS. Full package:
go test ./adk/pkg/models/→ ok.