-
Notifications
You must be signed in to change notification settings - Fork 29
🤖 fix: emit stream-error for pre-stream API failures #995
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
base: main
Are you sure you want to change the base?
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
If we do this I suggest changing the terminology on the frontend to be clear it doesn't map to an ai-sdk stream-error. E.g we could call it chat-error. Also this code is entwined with the auto retry logic so take care that doesn't regress. Otherwise I think this is the right architecture. |
When a chat message fails before streaming starts (e.g., invalid model, missing API key), emit a 'chat-error' event so the error is visible in the chat UI, not just as an easily-missed toast. - Add ChatErrorMessage schema, type, and type guard - Add emitChatError method in agentSession for pre-stream failures - Handle chat-error in WorkspaceStore and StreamingMessageAggregator - Add ChatErrorMessage UI component (displays 'Error' vs 'Stream Error') - chat-error is never auto-retryable (requires user action to fix) - Update retry eligibility to show retry UI for chat-error Distinguishes from stream-error which occurs during AI SDK streaming and may be transient/auto-retryable. _Generated with `mux`_
af745f8 to
91d77a6
Compare
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| metadata: { | ||
| partial: true, | ||
| error: data.error, | ||
| errorType: data.errorType, | ||
| timestamp: Date.now(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surface chat-error messages instead of stream-error
In handleChatError the pre-stream error is stored as a plain MuxMessage with only error metadata and no chat-error type, so getDisplayedMessages will still convert it into a stream-error entry. That means the new chat-error UI/logic never triggers: pre-stream failures such as unsupported providers or missing API keys are classified as retryable stream errors, allowing auto-resume to keep retrying instead of forcing user action.
Useful? React with 👍 / 👎.
When sendMessage failed before the stream started (e.g., invalid model, API key missing), the error was only shown as a toast which could be easily missed. The user would see their message in the chat but no response, with no indication of what went wrong.
Changes
agentSession.streamWithHistoryto emit astream-errorchat event when the stream fails to startemitStreamErrorhelper method that convertsSendMessageErrortoStreamErrorMessageWhy
The user would:
Now the error is clearly visible in the chat conversation itself.
Testing
sendMessageErrorunit tests continue to passGenerated with
mux