-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Security Assistant] Fix error handling on new chat #195507
Conversation
Pinging @elastic/security-solution (Team: SecuritySolution) |
`${LLM_TYPE}: ${actionResult?.message} - ${actionResult?.serviceMessage}` | ||
); | ||
if (actionResult?.serviceMessage) { | ||
error.name = actionResult?.serviceMessage; |
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.
generateChatTitle
will first look for error.name
and if not fall back to error.message
, in order to deliver a terse title. Therefore I'm putting the serviceMessage
(comes from LLM directly) on error.name
in each of these chat models.
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#7111[✅] Security Solution AI Assistant - Cypress: 50/50 tests passed. |
@elasticmachine merge upstream |
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.
Thanks for this fix @stephmilovic!
✅ Desk tested locally with OpenAI, Bedrock, and Gemini connectors, with new and valid -> invalid conversations
LGTM 🚀
@elasticmachine merge upstream |
@elasticmachine merge upstream |
Starting backport for target branches: 8.x |
💚 Build Succeeded
Metrics [docs]
History
|
(cherry picked from commit a15940d)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…196215) # Backport This will backport the following commits from `main` to `8.x`: - [[Security Assistant] Fix error handling on new chat (#195507)](#195507) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Steph Milovic","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-14T22:10:43Z","message":"[Security Assistant] Fix error handling on new chat (#195507)","sha":"a15940d9b939dbf29f74dbde28a2a543b8849cc1","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team: SecuritySolution","backport:prev-minor","Team:Security Generative AI","v8.16.0"],"title":"[Security Assistant] Fix error handling on new chat","number":195507,"url":"https://github.com/elastic/kibana/pull/195507","mergeCommit":{"message":"[Security Assistant] Fix error handling on new chat (#195507)","sha":"a15940d9b939dbf29f74dbde28a2a543b8849cc1"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195507","number":195507,"mergeCommit":{"message":"[Security Assistant] Fix error handling on new chat (#195507)","sha":"a15940d9b939dbf29f74dbde28a2a543b8849cc1"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Steph Milovic <[email protected]>
Summary
Resolves #191025
Fixes a bug in Security Assistant where the user's message disappears when a New chat is started with a bad connector.
Since the connector is bad and the first LLM call is to create the title, the error was thrown, the chain ended, and
handleLllmResponse
was called with the error message to save as an assistant message. Because the chain exited early, the title was not created, and the user's message was not persisted. By handling the error on the chat title and titling the conversation, the chain continues, saves the user's message, hits the LLM error again when it tries to send the conversation message, andhandleLllmResponse
is called with the error message.Previous behavior
a. Title is "New chat"
b. User's message disappears
c. Assistant error message persists
New behavior
a. Title is "Error name else error message, shortened to 60 characters"
b. User's message persists
c. Assistant error message persists
Cypress test
There was a cypress test that led me to discover this bug in the first place that I am now unskipping. I've got a successful Flakey Test Runner build to show you!