Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ describe('AgenticChatController', () => {
})
})

it('propagates error message to final chat result', async () => {
it('propagates model error back to client', async () => {
generateAssistantResponseStub.callsFake(() => {
throw new Error('Error')
})
Expand All @@ -931,9 +931,12 @@ describe('AgenticChatController', () => {
)

// These checks will fail if a response error is returned.
const typedChatResult = chatResult as ChatResult
assert.strictEqual(typedChatResult.type, 'answer')
assert.strictEqual(typedChatResult.body, 'Error')
const typedChatResult = chatResult as ResponseError<ChatResult>
assert.strictEqual(typedChatResult.message, 'Error')
assert.strictEqual(
typedChatResult.data?.body,
'An error occurred when communicating with the model, check the logs for more information.'
)
})

it('returns an auth follow up action if model request returns an auth error', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Will be deleted or merged.
*/

import * as path from 'path'

Check warning on line 6 in server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

View workflow job for this annotation

GitHub Actions / Test (Windows)

Do not import Node.js builtin module "path"

Check warning on line 6 in server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

View workflow job for this annotation

GitHub Actions / Test

Do not import Node.js builtin module "path"
import {
ChatTriggerType,
GenerateAssistantResponseCommandInput,
Expand Down Expand Up @@ -759,13 +759,13 @@
requestInput: RequestType,
makeRequest: (requestInput: RequestType) => Promise<ResponseType>
): Promise<ResponseType> {
this.#debug(`Q Backend Request: ${JSON.stringify(requestInput)}`)
this.#debug(`Q Model Request: ${JSON.stringify(requestInput)}`)
try {
const response = await makeRequest(requestInput)
this.#debug(`Q Backend Response: ${JSON.stringify(response)}`)
this.#debug(`Q Model Response: ${JSON.stringify(response)}`)
return response
} catch (e) {
this.#features.logging.error(`Error in call: ${JSON.stringify(e)}`)
this.#features.logging.error(`Q Model Error: ${JSON.stringify(e)}`)
throw new ModelServiceException(e as Error)
}
}
Expand Down Expand Up @@ -1130,14 +1130,12 @@
return createAuthFollowUpResult(authFollowType)
}

const backendError = err.cause
// Send the backend error message directly to the client to be displayed in chat.
return {
return new ResponseError<ChatResult>(LSPErrorCodes.RequestFailed, err.cause.message, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will the error cause message be logged and then the other body be shown to the user?

Copy link
Contributor Author

@Hweinstock Hweinstock Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, see the screenshot I added above. I was debating trying to parse the requestId and include it in the chat message (done on the agentic-chat vsc branch), but I think it makes more sense to be the logs since its a technical detail and only useful for internal users.

I think ideally we add a button to this chat message that opens the logs (like we do in most VSC error messages). However, this is not a p0 to me since it requires a decent amount of work to allow Flare to open IDE logs.

type: 'answer',
body: backendError.message,
body: 'An error occurred when communicating with the model, check the logs for more information.',
messageId: errorMessageId,
buttons: [],
}
})
}

async onInlineChatPrompt(
Expand Down
Loading