-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix-aborts #6604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix-aborts #6604
Conversation
👷 Deploy request for continuedev pending review.Visit the deploys page to approve it
|
When tested locally, this change does resolve: #6588 |
@sestinj I think this should be considered a critical hotfix for pre-release and the main branch, if you agree to the solution. Without this in place I can only issue one set of calls at a time before an abort occurs and I have to manually request the chat should continue. I suspect it's going to affect other providers. It's only getting caught in Bedrock.ts because of the extensive try/catch logic I think. It's likely going to exhibit other unexpected behavior or stalled streams/text corruption with other providers. |
@chezsmithy most providers handle the abort 499 code gracefully, whether in streamSse or explicitly. Maybe Bedrock is missing this handling? |
Just to clarify, what do you mean by one set of calls at a time in this context? |
@RomneyDa so what I see is the error is getting caught here: continue/core/llm/llms/Bedrock.ts Line 263 in 536f006
But the error isn't related to Bedrock, the error is related to the abortSignal getting aborted which causes the streaming to end. The pattern I see causing the issue is:
OR
I've also observed that periodically the assistent reponse from the toolCall becaomes garbled and is rendered out of order in the chat window. I'm thinking its a race condition that's being uncovered by the performance of the local tool calling. (guessing...) |
I created a local build using this fix, and I can confirm it's 100% fixed the issue for me. No more aborts, and no more text corruption. |
I'd say go for it, seems like the bug is a bit opaque but if this works I'd agree seems urgent |
…ware - Removed handleToolCallExecution from streamNormalInput.ts - Updated toolCallMiddleware to handle parallel tool calls with allowedWithoutPermission - Maintained original behavior where only allowedWithoutPermission tools execute automatically - Fixed all import dependencies and build issues 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
@chezsmithy I ended up merging my parallel tool calling PR into main, merged those changes in here and resolved the conflicts, mind taking a peek at 97b01b1 and verifying? Good to merge with your approval and will make it into pre-release tonight 🚀 |
@Patrick-Erichsen Testing now. Stand by. |
@Patrick-Erichsen My review got me to thinking... is this the actual solution? #6644 Seems to resolve the issue for me locally. Running tests now. |
Gonna back burner this for the simple option for now. Gonna close it, and reopen if needed. |
Description
Solving for the unexpected aborts being observed in Bedrock.ts in the streamChat function.
Fix Race Condition Between Stream Completion and Tool Call Execution
Problem Description
Fixed intermittent stream aborts and text corruption caused by a race condition between
streamChat
completion and tool call processing.Root Cause
streamNormalInput
immediately executed tool calls upon stream completionstreamUpdate
actions containing tool call deltas were still processing in Redux's action queueAWS Bedrock stream error (ECONNRESET): aborted
and concurrent stream text corruptionSymptoms
AWS Bedrock stream error (ECONNRESET): aborted
"The power, double, anThe power,d triple methods..."
Solutions Evaluated
Option A: useEffect Hook with Delays
Rejected: Arbitrary delays, still timing-dependent, component-coupled
Option B: Promise-Based State Settlement
Rejected: Complex integration, still relies on timing assumptions
Option C: Redux Middleware ✅ Selected
Why Redux Middleware?
setInactive
action is fully processedImplementation
Files Modified
gui/src/redux/middleware/toolCallMiddleware.ts
gui/src/redux/store.ts
- Added middleware to storegui/src/redux/thunks/streamNormalInput.ts
- Removed immediate tool executiongui/src/hooks/useToolCallTrigger.ts
- Replaced with middlewaregui/src/pages/gui/Chat.tsx
- Removed hook usageBefore (Race Condition)
After (Middleware Solution)
Results
The middleware approach provides a robust, deterministic solution that ensures tool calls execute at exactly the right moment in the Redux state transition lifecycle.
Checklist
Screenshots
[ For visual changes, include screenshots. Screen recordings are particularly helpful, and appreciated! ]
Tests
I have not updated any tests yet. Would like this reviewed and then I will look at test options. I will attempt to resolve any failing tests.
Summary by cubic
Fixed race conditions in Bedrock streamChat that caused stream aborts and text corruption by moving tool call execution to Redux middleware.