fix(anthropic): omit null system field in streaming payload (parity with chat)#602
Merged
ilvalerione merged 1 commit intoJul 15, 2026
Conversation
…ith chat) HandleChat sets 'system' conditionally, but HandleStream still sends 'system' => null when no system prompt is set. The request body is passed verbatim as JSON, and the Anthropic Messages API rejects "system": null with a validation error, making no-system streaming impossible. Mirror the chat path's conditional spread.
Contributor
|
Don't care about Thank you for the fix. |
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.
Problem
HandleChatsetssystemconditionally, but the Anthropic streaming path still sends the field unconditionally —src/Providers/Anthropic/HandleStream.php:GuzzleHttpClient::runRequestpasses the body verbatim viaRequestOptions::JSON, so an agent with no system prompt sends"system": null, which the Anthropic Messages API rejects with a validation error. Streaming without a system prompt is therefore impossible on the Anthropic provider.Fix
Mirror the chat path's conditional:
A possible follow-up (happy to include here if you'd like): the stream path also ignores
systemPromptBlocks, while chat now has asystemBlocksbranch — mirroring that would give streaming full parity with chat for prompt-caching users.Reproduction
Call
stream()on an Anthropic agent with no system prompt and inspect the outgoing request payload / API error response.Context
Carried as a downstream composer patch since v3.3.10; applies cleanly to current
3.x.