feat(agentStudio): cost control generic error handling#6997
feat(agentStudio): cost control generic error handling#6997pipeline1987 wants to merge 5 commits into
Conversation
Up to standards ✅🟢 Issues
|
More templates
algoliasearch-helper
instantsearch-ui-components
instantsearch.css
instantsearch.js
react-instantsearch
react-instantsearch-core
react-instantsearch-nextjs
react-instantsearch-router-nextjs
vue-instantsearch
commit: |
4152b4f to
05086fe
Compare
Haroenv
left a comment
There was a problem hiding this comment.
i think the main question is why we need to handle recursion and looping at all and the errors aren't just top-level
77b6224 to
5addb7a
Compare
afaik, the agent ai runs on LangGraph as a state graph with multiple LLM/tool steps, so there is a real recursion/step budget to enforce—not a single flat request/response. With streaming, the HTTP response has already started (200 + event stream), so failures that occur mid-run cannot be turned into a new top-level HTTP status; they have to be carried inside the stream protocol instead. it follows from how streaming and graph execution interact, but I could probably ask someone to check if that could be changed. |
5addb7a to
67be1bd
Compare
There was a problem hiding this comment.
Pull request overview
This PR improves Agent Studio chat “cost control” error handling end-to-end: it extracts meaningful backend error messages (HTTP + SSE), makes the stream processor more robust to sync callback failures, ensures UI components can access the underlying error message (while keeping the default UI copy generic), and resets the conversation id on clear so new messages don’t continue the old backend thread.
Changes:
- Transport + stream: parse
{ message: string }from non-OK HTTP responses; normalize SSEerrorText(including nested/double-encoded JSON); route synconChunkthrows toonError. - Chat lifecycle: rotate the conversation id on clear to start a new server-side thread.
- UI: plumb
errorintoChatMessages, adderrorMessage?: stringto error UI props, and allowtranslations.errorMessageto be a function; add/extend tests.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-instantsearch/src/widgets/Chat.tsx | Passes error into messagesProps so UI can access the last error. |
| packages/instantsearch.js/src/widgets/chat/chat.tsx | Passes error into messagesProps in the InstantSearch.js widget wrapper. |
| packages/instantsearch.js/src/lib/ai-lite/utils.ts | Adds getMessageFromStreamErrorText() to normalize stream error payloads. |
| packages/instantsearch.js/src/lib/ai-lite/transport.ts | Adds HTTP error body parsing for { message } and uses it on non-OK responses. |
| packages/instantsearch.js/src/lib/ai-lite/stream-parser.ts | Wraps onChunk to forward synchronous exceptions to onError. |
| packages/instantsearch.js/src/lib/ai-lite/index.ts | Exports getMessageFromStreamErrorText. |
| packages/instantsearch.js/src/lib/ai-lite/abstract-chat.ts | Makes chat id resettable and uses normalized stream error messages. |
| packages/instantsearch.js/src/lib/ai-lite/tests/utils.test.ts | Adds tests for getMessageFromStreamErrorText. |
| packages/instantsearch.js/src/lib/ai-lite/tests/stream-parser.test.ts | Adds test for sync-throw routing in processStream. |
| packages/instantsearch.js/src/connectors/chat/connectChat.ts | Resets conversation id when clearing finishes. |
| packages/instantsearch.js/src/connectors/chat/tests/connectChat-test.ts | Tests that conversation id changes after clearing. |
| packages/instantsearch-ui-components/src/components/chat/types.ts | Extends AbstractChat type with resetConversationId. |
| packages/instantsearch-ui-components/src/components/chat/ChatMessages.tsx | Adds error?: Error prop and passes errorMessage to error UI. |
| packages/instantsearch-ui-components/src/components/chat/ChatMessageError.tsx | Adds errorMessage?: string prop + functional translations.errorMessage. |
| packages/instantsearch-ui-components/src/components/chat/Chat.tsx | Passes error down into ChatMessages. |
| packages/instantsearch-ui-components/src/components/chat/tests/ChatMessages.test.tsx | Extends tests around error message exposure + translation function behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Summary
Result