Open
Conversation
added 2 commits
January 26, 2026 06:44
- Buffer ALL user messages during pending tool calls - Ensures strict message sequencing: assistant → tool responses → user messages - Fixes Azure 400 error: 'assistant with tool_calls must be followed by tool messages' - Prevents system-reminders and other user messages from breaking tool call sequences - Update version to 0.53.1 - Scope package to @AI-Manditrade - Linux AMD64 only distribution Tested and verified: - No Azure 400 errors with tool calls - 14 system-reminder messages properly buffered and released - All messages delivered to LLM in correct order
jedarden
pushed a commit
that referenced
this pull request
Jan 26, 2026
Azure OpenAI requires strict message sequencing where assistant messages with tool_calls must be immediately followed by all corresponding tool responses before any user messages can appear. This change: - Adds provider parameter to transformMessages() for provider-aware handling - Implements reorderMessagesForAzure() that buffers user messages appearing between tool calls and their responses, flushing them only after all pending tool responses are received - Applies reordering ONLY for Azure provider, not affecting other providers - Adds comprehensive tests for various Azure message ordering scenarios This is a properly scoped fix for PR #14, containing only the Go code changes without any package.json or metadata modifications.
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.
Claude Agent SDK keeps trying to send reminder messages as to the llm, which are also in between tool calls. OpenAI has a strict policy of only tool responses allowed after tool execution. This causes system crash. We've added filtering and buffering to catch these before they get sent to openai directly or via Azure.