Repository navigation
fix(commandcode): retry on transient stream error and avoid fake stop chunks - #4130
Closed
Christian-Gennari wants to merge 1 commit into
Closed
Christian-Gennari wants to merge 1 commit into
Christian-Gennari wants to merge 1 commit into
Conversation
Owner
|
Thanks @Christian-Gennari for the contribution! Reviewed and merged into master. 🙏 |
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 #4129
Summary
Improves CommandCode upstream reliability by automatically retrying transient server connection drops, preventing mid-stream errors from emitting fake
stopchunks to clients, and ensuring assistant turns with tool calls pass reasoning blocks.To be clear, the primary root cause for the connection drops is upstream instability on CommandCode's own infrastructure (tracked in CommandCodeAI/command-code#597). This PR provides defensive resiliency on 9Router's side so downstream clients do not experience interrupted turns while CommandCode resolves their backend stability.
Details
CommandCodeExecutor.execute()retries upstream up to 2 times with backoff wheninspectAndWrapCommandCodeResponsereturns 502/503/504 status codes.commandcode-to-openai.jsnow throws on upstream error events instead of emitting[CommandCode error: ...]followed byfinish_reason: "stop", preventing clients from treating server disconnects as valid completions.openai-to-commandcode.jsincludes reasoning blocks for assistant messages with tool calls or thought content to comply with upstream thinking mode expectations.tests/unit/commandcode-executor.test.jsto verify retry recovery and status handling.