-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(orchestrator): surface AI error results instead of silent drop (fixes #1076) #1084
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -916,6 +916,7 @@ async function handleStreamMode( | |
| ): Promise<void> { | ||
| const allMessages: string[] = []; | ||
| let newSessionId: string | undefined; | ||
| let errorResult: { subtype?: string } | undefined; | ||
| let commandDetected = false; | ||
|
|
||
| for await (const msg of aiClient.sendQuery( | ||
|
|
@@ -959,13 +960,7 @@ async function handleStreamMode( | |
| newSessionId = msg.sessionId; | ||
| } | ||
| if (msg.isError) { | ||
| getLog().warn({ conversationId, errorSubtype: msg.errorSubtype }, 'ai_result_error'); | ||
| const syntheticError = new Error(msg.errorSubtype ?? 'AI result error'); | ||
| await platform.sendMessage(conversationId, classifyAndFormatError(syntheticError)); | ||
| if (newSessionId) { | ||
| await tryPersistSessionId(session.id, newSessionId); | ||
| } | ||
| return; | ||
| errorResult = { subtype: msg.errorSubtype }; | ||
| } | ||
| if (!commandDetected && platform.sendStructuredEvent) { | ||
| await platform.sendStructuredEvent(conversationId, msg); | ||
|
|
@@ -978,7 +973,18 @@ async function handleStreamMode( | |
| } | ||
|
|
||
| if (allMessages.length === 0) { | ||
| getLog().debug({ conversationId }, 'no_ai_response'); | ||
| if (errorResult) { | ||
| const providerLabel = aiClient.getType() === 'claude' ? 'Claude' : 'AI'; | ||
| const hint = | ||
| errorResult.subtype === 'authentication_error' | ||
| ? `Check your ${providerLabel} credentials or use /reset.` | ||
| : 'Check server logs for details.'; | ||
| await platform.sendMessage( | ||
| conversationId, | ||
| `AI error${errorResult.subtype ? ` (${errorResult.subtype})` : ''}. ${hint}` | ||
| ); | ||
| } | ||
| getLog().debug({ conversationId, errorResult }, 'no_ai_response'); | ||
| return; | ||
|
Comment on lines
+987
to
988
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename this log event to match the repo convention.
As per coding guidelines, "Use Also applies to: 1057-1058 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
|
|
@@ -1046,6 +1052,7 @@ async function handleBatchMode( | |
| let assistantChunksTruncated = false; | ||
| let totalChunksTruncated = false; | ||
| let newSessionId: string | undefined; | ||
| let errorResult: { subtype?: string } | undefined; | ||
| let commandDetected = false; | ||
|
|
||
| for await (const msg of aiClient.sendQuery( | ||
|
|
@@ -1082,13 +1089,7 @@ async function handleBatchMode( | |
| newSessionId = msg.sessionId; | ||
| } | ||
| if (msg.isError) { | ||
| getLog().warn({ conversationId, errorSubtype: msg.errorSubtype }, 'ai_result_error'); | ||
| const syntheticError = new Error(msg.errorSubtype ?? 'AI result error'); | ||
| await platform.sendMessage(conversationId, classifyAndFormatError(syntheticError)); | ||
| if (newSessionId) { | ||
| await tryPersistSessionId(session.id, newSessionId); | ||
| } | ||
| return; | ||
| errorResult = { subtype: msg.errorSubtype }; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1123,7 +1124,18 @@ async function handleBatchMode( | |
| const finalMessage = filterToolIndicators(assistantMessages); | ||
|
|
||
| if (!finalMessage) { | ||
| getLog().debug({ conversationId }, 'no_ai_response'); | ||
| if (errorResult) { | ||
| const providerLabel = aiClient.getType() === 'claude' ? 'Claude' : 'AI'; | ||
| const hint = | ||
| errorResult.subtype === 'authentication_error' | ||
| ? `Check your ${providerLabel} credentials or use /reset.` | ||
| : 'Check server logs for details.'; | ||
| await platform.sendMessage( | ||
| conversationId, | ||
| `AI error${errorResult.subtype ? ` (${errorResult.subtype})` : ''}. ${hint}` | ||
| ); | ||
| } | ||
| getLog().debug({ conversationId, errorResult }, 'no_ai_response'); | ||
| return; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.