Skip to content

fix(openai): accept null tool_call arguments in streaming chunks - #9035

Merged
jh-block merged 2 commits into
aaif-goose:mainfrom
SarthakB11:fix/issue-8991
May 6, 2026
Merged

jh-block merged 2 commits into
aaif-goose:mainfrom
SarthakB11:fix/issue-8991

Conversation

@SarthakB11

Copy link
Copy Markdown
Contributor

Summary

DeltaToolCallFunction.arguments is a String with #[serde(default)]. serde(default) only fires when the field is missing, so a streaming chunk that sends "arguments": null (deepseek-v4-pro in #8991) blows up the whole chunk parse with invalid type: null, expected a string and the tool call gets dropped.

Add a deserialize_null_default_string helper that maps both missing and explicit null to "", and use it on arguments. The field stays a String, so the push_str / clone sites that concatenate streaming deltas don't change.

Kept it as String rather than switching to Option<String> so the change is local to this one field and doesn't ripple through the streaming accumulator.

Testing

  • Added test_delta_tool_call_function_accepts_null_arguments covering the null, missing, and populated cases.
  • cargo test -p goose --lib providers::formats::openai

Related Issues

Fixes #8991

@jh-block
jh-block added this pull request to the merge queue May 6, 2026
Merged via the queue into aaif-goose:main with commit b1ab216 May 6, 2026
22 checks passed
lifeizhou-ap added a commit that referenced this pull request May 7, 2026
…-refactor

* origin/main:
  refactor: switch to official new rust-sdk for ACP (#9062)
  refactor(goose2): remove attachment preamble (#9052)
  Align CODEOWNERS with pull request review rules in GOVERNANCE.md (#9056)
  bring MAINTAINERS.md up to date (#9053)
  feat(acp): expose built-in skills through sources list acp calls (#9045)
  add provider-first onboarding (#9039)
  feat: ACP streamable http spec compliance (#9034)
  Skip automatic fix which crashes (#9036)
  fix(openai): accept null tool_call arguments in streaming chunks (#9035)

Signed-off-by: Lifei Zhou <[email protected]>

# Conflicts:
#	ui/goose2/src/features/chat/hooks/useChat.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to parse streaming chunk: invalid type: null when llm response tool_calls function arguments is null

2 participants