Skip to content

Conversation

@zacharyparikh
Copy link
Contributor

Summary

Add conversation round errors

  • Error details panel
  • Round retry button
image

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.

- Error details panel
- Round retry button
@zacharyparikh zacharyparikh requested a review from a team as a code owner July 29, 2025 17:45
@zacharyparikh zacharyparikh added backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes labels Jul 29, 2025
@zacharyparikh
Copy link
Contributor Author

@elasticmachine merge upstream

export const RoundError: React.FC<RoundErrorProps> = ({ error }) => {
const getStackTrace = (error: unknown) => {
if (error instanceof Error && typeof error.stack === 'string') {
return error.stack;
Copy link
Contributor

@jedrazb jedrazb Jul 30, 2025

Choose a reason for hiding this comment

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

Aren't stack traces of bundled js basically useless? I couldn't reproduce but the most common chat error I'm getting is hitting context length window (?) with long tool calls

I see sth like this in toast:

Error: event: error
data: {"error":{"code":"bad_request","message":"Received a bad request status code for request from inference entity id [.rainbow-sprinkles-elastic] status [400].

Hope the message will be included in the error details. Can we verify this somehow? (I couldn't reproduce this easily)

Copy link
Contributor

Choose a reason for hiding this comment

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

I tried adding throw createInternalError('oh no internal error'); in the /chat callConverse function and the message didn't get propagated

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay yeah you're right. Error.prototype.stack is not the place we should be looking. Let me look a bit closer at the error types to see what we should be using instead here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think maybe the errors that are thrown on the server are not flowing through properly to the client. When I catch an error in the frontend observable it no longer has the OnechatError type. I'm looking into it now, but it seems like maybe the HTTP layer is catching and then repackaging the error as a generic Internal Server Error.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm I had to deal with that in #229254 and this formatter logic helped and i see you are using this. all onechat errors are instances of ServerSentEventError and the default err.message property is not populated and yeah something felt very off when working with onechat errors on client side. I'm fine to look into this as a followup

Comment on lines +29 to +30
const [message, setMessage] = useState<string>('');
const { sendMessage, isResponseLoading, error, pendingMessage, retry } = useSendMessageMutation();
Copy link
Contributor

@jedrazb jedrazb Jul 30, 2025

Choose a reason for hiding this comment

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

it feels slightly off to me that message lives in component and pendingMessage lives in a hook?

I feel like those things are closely tied together, should this be a single hook perhaps?

That would be a nicer interface if other team wants to use onechat's building blocks. I have useChat in mind as an example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree. I plan on re-organizing this state in a follow up PR. I'll probably create a MessagesProvider which will provide the state for the current and pending messages, and a ConversationProvider which will provide the state for the current conversation.

Copy link
Member

Choose a reason for hiding this comment

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

question (maybe nitpick): does it make sense to separate those out into two providers or a single provider that represents the state of the current conversation including the messages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you might be right. My thinking was to have separate contexts so that if there was a component that is only concerned with sending messages / messages state, they would only need to subscribe to the Messages context and not the entire Conversation context. Because when any state changes in a context, all of it's subscribers must re-render even if not subscribed to the state that changed. I think we can get around this by providing custom hooks that memoize the state though. I'll do more discovery on how we should structure soon. May also be that we only really need a MessagesProvider and that the conversation stuff doesn't really need it's own context.

Copy link
Contributor

@jedrazb jedrazb left a comment

Choose a reason for hiding this comment

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

LGTM! followup to reorganize chat hooks and improve passing error messages/bodies to client

})
);
};
const removeNewConversationQuery = () => {
Copy link
Member

Choose a reason for hiding this comment

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

it seems to keep the first conversation message in, showing a repeat

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was oddly enough caused by not having the analytics eventType registered properly. Caused a silent error to be thrown in the useMutation onError callback which caused onSettled to not be called at all. I'm registering the event type properly now.

One caveat to note here: if there is an error occurs in the first message of a conversation, it will throw away the whole conversation. This will be fixed in the follow up state management issue. I don't believe this is a regression, the production code should also behave this way.

if (isLoading) {
return (
<div css={loadingStyles}>
<EuiLoadingElastic size="l" aria-label={loadingLabel} />
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: can use FormattedMessage here since the label is only used once?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How does that work? I thought FormattedMessage was only for things displayed to the DOM? Doesn't aria-label only accept a string and not a React Node?

Copy link
Member

Choose a reason for hiding this comment

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

aaah i didn't spot its also used in the aria-label and now makes sense why you have it as a variable. my bad. Yes your approach is fine :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although now that you mention it, I should i18n-ize the EuiAvatar names, right?

Copy link
Member

Choose a reason for hiding this comment

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

Yes good spot - we should be as used as a title tag.

@zacharyparikh
Copy link
Contributor Author

@elasticmachine merge upstream

@zacharyparikh
Copy link
Contributor Author

@elasticmachine merge upstream

@zacharyparikh zacharyparikh requested a review from a team as a code owner August 1, 2025 16:51
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
onechat 410 415 +5

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
onechat 597.3KB 600.5KB +3.1KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
onechat 11.6KB 12.7KB +1.1KB

History

@zacharyparikh zacharyparikh merged commit adf8916 into elastic:main Aug 1, 2025
12 checks passed
szaffarano pushed a commit to szaffarano/kibana that referenced this pull request Aug 5, 2025
## Summary

Add conversation round errors
- Error details panel
- Round retry button

<img width="1674" height="1476" alt="image"
src="https://github.com/user-attachments/assets/802a619d-aa25-4f7a-bf70-39e6a8cda2ca"
/>

### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
delanni pushed a commit to delanni/kibana that referenced this pull request Aug 5, 2025
## Summary

Add conversation round errors
- Error details panel
- Round retry button

<img width="1674" height="1476" alt="image"
src="https://github.com/user-attachments/assets/802a619d-aa25-4f7a-bf70-39e6a8cda2ca"
/>

### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@wildemat wildemat mentioned this pull request Aug 7, 2025
10 tasks
NicholasPeretti pushed a commit to NicholasPeretti/kibana that referenced this pull request Aug 18, 2025
## Summary

Add conversation round errors
- Error details panel
- Round retry button

<img width="1674" height="1476" alt="image"
src="https://github.com/user-attachments/assets/802a619d-aa25-4f7a-bf70-39e6a8cda2ca"
/>

### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants