Skip to content

Conversation

@rabi
Copy link
Contributor

@rabi rabi commented Dec 31, 2025

Summary

Some LLM providers (e.g., vLLM with QwQ models) send tool_call chunks where the first chunk contains only the function name without arguments, and subsequent chunks contain the arguments. This caused deserialization to fail with 'missing field arguments'.

The deserialization error was silently treated as end-of-stream because 'while let Some(Ok(...))' doesn't match 'Some(Err(...))' - it just exits the loop as if the stream had completed normally.

Changes:

  • Added #[serde(default)] to DeltaToolCallFunction.arguments in openai.rs to handle missing arguments by defaulting to empty string
  • Fixed stream consumption pattern: changed 'while let Some(Ok(...))' to 'while let Some(result)' with explicit error propagation via '?'
  • Added test for stream error propagation

Type of Change

  • Feature
  • Bug fix
  • Refactor / Code quality
  • Performance improvement
  • Documentation
  • Tests
  • Security fix
  • Build / Release
  • Other (specify below)

AI Assistance

  • This PR was created or reviewed with AI assistance

Testing

Unit and manual testing with vLLM.

Some LLM providers (e.g., vLLM with QwQ models) send tool_call chunks
where the first chunk contains only the function name without arguments,
and subsequent chunks contain the arguments. This caused deserialization
to fail with 'missing field arguments'.

The deserialization error was silently treated as end-of-stream because
'while let Some(Ok(...))' doesn't match 'Some(Err(...))' - it just exits
the loop as if the stream had completed normally.

Changes:
- Added #[serde(default)] to DeltaToolCallFunction.arguments in openai.rs
  to handle missing arguments by defaulting to empty string
- Fixed stream consumption pattern: changed 'while let Some(Ok(...))'
  to 'while let Some(result)' with explicit error propagation via '?'
- Added test for stream error propagation

Signed-off-by: rabi <[email protected]>
@rabi rabi changed the title fix: make tool_call arguments optional and fix silent stream termination fix(openai): make tool_call arguments optional and fix silent stream termination Jan 5, 2026
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.

1 participant