Skip to content

[9.0] [Obs AI Assistant]fixing error - Display results and Visualize query Bedrock Error (#218213)#218716

Merged
arturoliduena merged 1 commit intoelastic:9.0from
arturoliduena:backport/9.0/pr-218213
Apr 22, 2025
Merged

[9.0] [Obs AI Assistant]fixing error - Display results and Visualize query Bedrock Error (#218213)#218716
arturoliduena merged 1 commit intoelastic:9.0from
arturoliduena:backport/9.0/pr-218213

Conversation

@arturoliduena
Copy link
Contributor

Backport

This will backport the following commits from main to 9.0:

Questions ?

Please refer to the Backport tool documentation

…Bedrock Error (elastic#218213)

### Fix: Bedrock Streaming Error on ES|QL Actions

#### Summary

When an ES|QL is generated, we present two action buttons:
- Visualize Query
- Display Results

These actions were not working as expected when using Bedrock as the
model provider.

#### Error Details
```txt
Encountered error in Bedrock stream of type validationException messages.8: Did not find 1 `tool_result` block(s) at the beginning of this message. Messages following `tool_use` blocks must begin with a matching number of `tool_result` blocks.
```
#### Root Cause

We were sending a tool_use block in the assistant message without
immediately following it with the corresponding tool_result block. This
violates Bedrock’s message protocol.

(cherry picked from commit 33993b7)

# Conflicts:
#	x-pack/platform/packages/shared/kbn-ai-assistant/src/chat/chat_body.tsx
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #15 / SuggestUsersPopover calls onUsersChange when 1 user is selected
  • [job] [logs] Jest Tests #15 / UserToolTip renders the tooltip when hovering

Metrics [docs]

Async chunks

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

id before after diff
observabilityAIAssistantApp 249.9KB 249.9KB +27.0B
searchAssistant 146.3KB 146.3KB +27.0B
total +54.0B

Page load bundle

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

id before after diff
observabilityAIAssistant 38.0KB 37.9KB -41.0B

@arturoliduena arturoliduena merged commit f06981e into elastic:9.0 Apr 22, 2025
12 checks passed
@botelastic botelastic bot added the Team:Obs AI Assistant Observability AI Assistant label Apr 22, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant)

arturoliduena added a commit that referenced this pull request Jun 3, 2025
… query Bedrock Error (#218213) (#222298)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Obs AI Assistant]fixing error - Display results and Visualize query
Bedrock Error (#218213)](#218213)

<!--- Backport version: 10.0.0 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Arturo
Lidueña","email":"arturo.liduena@elastic.co"},"sourceCommit":{"committedDate":"2025-04-21T08:51:18Z","message":"[Obs
AI Assistant]fixing error - Display results and Visualize query Bedrock
Error (#218213)\n\n### Fix: Bedrock Streaming Error on ES|QL
Actions\n\n#### Summary\n\nWhen an ES|QL is generated, we present two
action buttons:\n- Visualize Query\n- Display Results\n\nThese actions
were not working as expected when using Bedrock as the\nmodel
provider.\n\n#### Error Details\n```txt\nEncountered error in Bedrock
stream of type validationException messages.8: Did not find 1
`tool_result` block(s) at the beginning of this message. Messages
following `tool_use` blocks must begin with a matching number of
`tool_result` blocks.\n```\n#### Root Cause\n\nWe were sending a
tool_use block in the assistant message without\nimmediately following
it with the corresponding tool_result block. This\nviolates Bedrock’s
message
protocol.","sha":"33993b7123bc0d6c85d9c42b15610cc0d5092281","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:prev-minor","Team:Obs
AI
Assistant","ci:project-deploy-observability","v9.1.0","v9.0.1"],"title":"[Obs
AI Assistant]fixing error - Display results and Visualize query Bedrock
Error","number":218213,"url":"https://github.com/elastic/kibana/pull/218213","mergeCommit":{"message":"[Obs
AI Assistant]fixing error - Display results and Visualize query Bedrock
Error (#218213)\n\n### Fix: Bedrock Streaming Error on ES|QL
Actions\n\n#### Summary\n\nWhen an ES|QL is generated, we present two
action buttons:\n- Visualize Query\n- Display Results\n\nThese actions
were not working as expected when using Bedrock as the\nmodel
provider.\n\n#### Error Details\n```txt\nEncountered error in Bedrock
stream of type validationException messages.8: Did not find 1
`tool_result` block(s) at the beginning of this message. Messages
following `tool_use` blocks must begin with a matching number of
`tool_result` blocks.\n```\n#### Root Cause\n\nWe were sending a
tool_use block in the assistant message without\nimmediately following
it with the corresponding tool_result block. This\nviolates Bedrock’s
message
protocol.","sha":"33993b7123bc0d6c85d9c42b15610cc0d5092281"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/218213","number":218213,"mergeCommit":{"message":"[Obs
AI Assistant]fixing error - Display results and Visualize query Bedrock
Error (#218213)\n\n### Fix: Bedrock Streaming Error on ES|QL
Actions\n\n#### Summary\n\nWhen an ES|QL is generated, we present two
action buttons:\n- Visualize Query\n- Display Results\n\nThese actions
were not working as expected when using Bedrock as the\nmodel
provider.\n\n#### Error Details\n```txt\nEncountered error in Bedrock
stream of type validationException messages.8: Did not find 1
`tool_result` block(s) at the beginning of this message. Messages
following `tool_use` blocks must begin with a matching number of
`tool_result` blocks.\n```\n#### Root Cause\n\nWe were sending a
tool_use block in the assistant message without\nimmediately following
it with the corresponding tool_result block. This\nviolates Bedrock’s
message
protocol.","sha":"33993b7123bc0d6c85d9c42b15610cc0d5092281"}},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/218716","number":218716,"state":"MERGED","mergeCommit":{"sha":"f06981e08ad2dcd663bc6258b37c600bc68cd207","message":"[9.0]
[Obs AI Assistant]fixing error - Display results and Visualize query
Bedrock Error (#218213) (#218716)\n\n# Backport\n\nThis will backport
the following commits from `main` to `9.0`:\n- [[Obs AI Assistant]fixing
error - Display results and Visualize query\nBedrock Error
(#218213)](https://github.com/elastic/kibana/pull/218213)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n"}}]}]
BACKPORT-->
arturoliduena added a commit that referenced this pull request Jul 11, 2025
… query Bedrock Error (#218213) (#227656)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Obs AI Assistant]fixing error - Display results and Visualize query
Bedrock Error (#218213)](#218213)

<!--- Backport version: 10.0.1 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Arturo
Lidueña","email":"arturo.liduena@elastic.co"},"sourceCommit":{"committedDate":"2025-04-21T08:51:18Z","message":"[Obs
AI Assistant]fixing error - Display results and Visualize query Bedrock
Error (#218213)\n\n### Fix: Bedrock Streaming Error on ES|QL
Actions\n\n#### Summary\n\nWhen an ES|QL is generated, we present two
action buttons:\n- Visualize Query\n- Display Results\n\nThese actions
were not working as expected when using Bedrock as the\nmodel
provider.\n\n#### Error Details\n```txt\nEncountered error in Bedrock
stream of type validationException messages.8: Did not find 1
`tool_result` block(s) at the beginning of this message. Messages
following `tool_use` blocks must begin with a matching number of
`tool_result` blocks.\n```\n#### Root Cause\n\nWe were sending a
tool_use block in the assistant message without\nimmediately following
it with the corresponding tool_result block. This\nviolates Bedrock’s
message
protocol.","sha":"33993b7123bc0d6c85d9c42b15610cc0d5092281","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:prev-minor","Team:Obs
AI
Assistant","ci:project-deploy-observability","v9.1.0","v8.19.0","v9.0.1"],"title":"[Obs
AI Assistant]fixing error - Display results and Visualize query Bedrock
Error","number":218213,"url":"https://github.com/elastic/kibana/pull/218213","mergeCommit":{"message":"[Obs
AI Assistant]fixing error - Display results and Visualize query Bedrock
Error (#218213)\n\n### Fix: Bedrock Streaming Error on ES|QL
Actions\n\n#### Summary\n\nWhen an ES|QL is generated, we present two
action buttons:\n- Visualize Query\n- Display Results\n\nThese actions
were not working as expected when using Bedrock as the\nmodel
provider.\n\n#### Error Details\n```txt\nEncountered error in Bedrock
stream of type validationException messages.8: Did not find 1
`tool_result` block(s) at the beginning of this message. Messages
following `tool_use` blocks must begin with a matching number of
`tool_result` blocks.\n```\n#### Root Cause\n\nWe were sending a
tool_use block in the assistant message without\nimmediately following
it with the corresponding tool_result block. This\nviolates Bedrock’s
message
protocol.","sha":"33993b7123bc0d6c85d9c42b15610cc0d5092281"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/218213","number":218213,"mergeCommit":{"message":"[Obs
AI Assistant]fixing error - Display results and Visualize query Bedrock
Error (#218213)\n\n### Fix: Bedrock Streaming Error on ES|QL
Actions\n\n#### Summary\n\nWhen an ES|QL is generated, we present two
action buttons:\n- Visualize Query\n- Display Results\n\nThese actions
were not working as expected when using Bedrock as the\nmodel
provider.\n\n#### Error Details\n```txt\nEncountered error in Bedrock
stream of type validationException messages.8: Did not find 1
`tool_result` block(s) at the beginning of this message. Messages
following `tool_use` blocks must begin with a matching number of
`tool_result` blocks.\n```\n#### Root Cause\n\nWe were sending a
tool_use block in the assistant message without\nimmediately following
it with the corresponding tool_result block. This\nviolates Bedrock’s
message
protocol.","sha":"33993b7123bc0d6c85d9c42b15610cc0d5092281"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/222298","number":222298,"state":"MERGED","mergeCommit":{"sha":"a67bac807c5c7e3a940296d1bfd969d5354a5926","message":"[8.19]
[Obs AI Assistant]fixing error - Display results and Visualize query
Bedrock Error (#218213) (#222298)\n\n# Backport\n\nThis will backport
the following commits from `main` to `8.19`:\n- [[Obs AI
Assistant]fixing error - Display results and Visualize query\nBedrock
Error
(#218213)](https://github.com/elastic/kibana/pull/218213)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n"}},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/218716","number":218716,"state":"MERGED","mergeCommit":{"sha":"f06981e08ad2dcd663bc6258b37c600bc68cd207","message":"[9.0]
[Obs AI Assistant]fixing error - Display results and Visualize query
Bedrock Error (#218213) (#218716)\n\n# Backport\n\nThis will backport
the following commits from `main` to `9.0`:\n- [[Obs AI Assistant]fixing
error - Display results and Visualize query\nBedrock Error
(#218213)](https://github.com/elastic/kibana/pull/218213)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n"}}]}]
BACKPORT-->

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

Labels

backport This PR is a backport of another PR Team:Obs AI Assistant Observability AI Assistant

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants