[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked#227462
[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked#227462viduni94 merged 6 commits intoelastic:mainfrom
Conversation
x-pack/platform/packages/shared/kbn-ai-assistant/src/chat/chat_body.tsx
Outdated
Show resolved
Hide resolved
|
Also tested auto visualization: Screen.Recording.2025-07-10.at.12.22.21.PM.mov |
6a40d44 to
de1dd09
Compare
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
|
Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
💚 Build Succeeded
Metrics [docs]Async chunks
Historycc @viduni94 |
|
Tested on Elastic Managed LLM, Bedrock 3.5 v2, Bedrock 3.7, Azture gpt4o. Confirmed no longer seeing the behavior with 2 events and no response when clicking Display Results in Claude models. |
Thanks a lot for testing @neptunian |
|
I tested this with Azure GPT4o, Gemini 2.5, Claude 3.5, Claude 3.7 and Elastic Managed LLM and it worked in all cases :) |
Thanks a lot for testing @eleonoramicozzi |
|
Final testing:
|
|
Starting backport for target branches: 8.18, 8.19, 9.0, 9.1 https://github.com/elastic/kibana/actions/runs/16219962728 |
…ions are clicked (elastic#227462) Closes elastic/obs-ai-team#309 ## Summary This PR improves the `Display Results` and `visualize this query` actions by injecting a user prompt first and then the tool call to maintain correct message ordering. This fixes the empty message that was observed when visualize this query was clicked. However, in any case, if an empty message is received this should be handled separately to avoid breaking the conversation flow. ## Testing instructions: 1. Generate some logs 2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude 3.5, Claude 3.7, GPT-4, etc) 3. Ask the assistant to generate a query 4. Click on `Display results` -- the results should be shown and the user should be able to continue the conversation 5. Click on `Visualize this query` -- the visualization should be shown and the user should be able to continue the conversation ## Traces with each model: - EIS (Visualize this query) - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D <img width="715" height="868" alt="image" src="https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da" /> - EIS (Display results) - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D https://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669 - Bedrock+Claude 3.7 - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D <img width="709" height="889" alt="image" src="https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227" /> - Bedrock+Claude 3.5 - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D <img width="714" height="942" alt="image" src="https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139" /> - AzureOpenAI+GPT 4.1 - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D <img width="715" height="877" alt="image" src="https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d" /> - Gemini 2.0 Flash - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D <img width="709" height="880" alt="image" src="https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b" /> - Gemini 2.5 Flash - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D <img width="708" height="872" alt="image" src="https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061" /> ### Checklist - [x] 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) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. (cherry picked from commit 021b308)
…ions are clicked (elastic#227462) Closes elastic/obs-ai-team#309 ## Summary This PR improves the `Display Results` and `visualize this query` actions by injecting a user prompt first and then the tool call to maintain correct message ordering. This fixes the empty message that was observed when visualize this query was clicked. However, in any case, if an empty message is received this should be handled separately to avoid breaking the conversation flow. ## Testing instructions: 1. Generate some logs 2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude 3.5, Claude 3.7, GPT-4, etc) 3. Ask the assistant to generate a query 4. Click on `Display results` -- the results should be shown and the user should be able to continue the conversation 5. Click on `Visualize this query` -- the visualization should be shown and the user should be able to continue the conversation ## Traces with each model: - EIS (Visualize this query) - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D <img width="715" height="868" alt="image" src="https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da" /> - EIS (Display results) - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D https://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669 - Bedrock+Claude 3.7 - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D <img width="709" height="889" alt="image" src="https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227" /> - Bedrock+Claude 3.5 - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D <img width="714" height="942" alt="image" src="https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139" /> - AzureOpenAI+GPT 4.1 - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D <img width="715" height="877" alt="image" src="https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d" /> - Gemini 2.0 Flash - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D <img width="709" height="880" alt="image" src="https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b" /> - Gemini 2.5 Flash - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D <img width="708" height="872" alt="image" src="https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061" /> ### Checklist - [x] 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) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. (cherry picked from commit 021b308)
…ions are clicked (elastic#227462) Closes elastic/obs-ai-team#309 ## Summary This PR improves the `Display Results` and `visualize this query` actions by injecting a user prompt first and then the tool call to maintain correct message ordering. This fixes the empty message that was observed when visualize this query was clicked. However, in any case, if an empty message is received this should be handled separately to avoid breaking the conversation flow. ## Testing instructions: 1. Generate some logs 2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude 3.5, Claude 3.7, GPT-4, etc) 3. Ask the assistant to generate a query 4. Click on `Display results` -- the results should be shown and the user should be able to continue the conversation 5. Click on `Visualize this query` -- the visualization should be shown and the user should be able to continue the conversation ## Traces with each model: - EIS (Visualize this query) - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D <img width="715" height="868" alt="image" src="https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da" /> - EIS (Display results) - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D https://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669 - Bedrock+Claude 3.7 - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D <img width="709" height="889" alt="image" src="https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227" /> - Bedrock+Claude 3.5 - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D <img width="714" height="942" alt="image" src="https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139" /> - AzureOpenAI+GPT 4.1 - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D <img width="715" height="877" alt="image" src="https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d" /> - Gemini 2.0 Flash - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D <img width="709" height="880" alt="image" src="https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b" /> - Gemini 2.5 Flash - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D <img width="708" height="872" alt="image" src="https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061" /> ### Checklist - [x] 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) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. (cherry picked from commit 021b308)
💔 Some backports could not be created
Note: Successful backport PRs will be merged automatically after passing CI. Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…ions are clicked (elastic#227462) Closes elastic/obs-ai-team#309 ## Summary This PR improves the `Display Results` and `visualize this query` actions by injecting a user prompt first and then the tool call to maintain correct message ordering. This fixes the empty message that was observed when visualize this query was clicked. However, in any case, if an empty message is received this should be handled separately to avoid breaking the conversation flow. ## Testing instructions: 1. Generate some logs 2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude 3.5, Claude 3.7, GPT-4, etc) 3. Ask the assistant to generate a query 4. Click on `Display results` -- the results should be shown and the user should be able to continue the conversation 5. Click on `Visualize this query` -- the visualization should be shown and the user should be able to continue the conversation ## Traces with each model: - EIS (Visualize this query) - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D <img width="715" height="868" alt="image" src="https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da" /> - EIS (Display results) - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D https://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669 - Bedrock+Claude 3.7 - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D <img width="709" height="889" alt="image" src="https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227" /> - Bedrock+Claude 3.5 - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D <img width="714" height="942" alt="image" src="https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139" /> - AzureOpenAI+GPT 4.1 - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D <img width="715" height="877" alt="image" src="https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d" /> - Gemini 2.0 Flash - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D <img width="709" height="880" alt="image" src="https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b" /> - Gemini 2.5 Flash - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D <img width="708" height="872" alt="image" src="https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061" /> ### Checklist - [x] 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) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. (cherry picked from commit 021b308) # Conflicts: # x-pack/platform/packages/shared/kbn-ai-assistant/src/chat/chat_body.tsx
…ery actions are clicked (#227462) (#227641) # Backport This will backport the following commits from `main` to `8.19`: - [[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)](#227462) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Viduni Wickramarachchi","email":"viduni.wickramarachchi@elastic.co"},"sourceCommit":{"committedDate":"2025-07-11T12:25:04Z","message":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/309\n\n## Summary\n\nThis PR improves the `Display Results` and `visualize this query`\nactions by injecting a user prompt first and then the tool call to\nmaintain correct message ordering. This fixes the empty message that was\nobserved when visualize this query was clicked.\n\nHowever, in any case, if an empty message is received this should be\nhandled separately to avoid breaking the conversation flow.\n\n## Testing instructions:\n1. Generate some logs\n2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude\n3.5, Claude 3.7, GPT-4, etc)\n3. Ask the assistant to generate a query\n4. Click on `Display results` -- the results should be shown and the\nuser should be able to continue the conversation\n5. Click on `Visualize this query` -- the visualization should be shown\nand the user should be able to continue the conversation\n\n## Traces with each model:\n\n- EIS (Visualize this query) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D\n<img width=\"715\" height=\"868\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da\"\n/>\n\n- EIS (Display results) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D\n\n\nhttps://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669\n\n- Bedrock+Claude 3.7 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D\n<img width=\"709\" height=\"889\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227\"\n/>\n\n\n- Bedrock+Claude 3.5 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D\n<img width=\"714\" height=\"942\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139\"\n/>\n\n\n- AzureOpenAI+GPT 4.1 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D\n<img width=\"715\" height=\"877\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d\"\n/>\n\n\n- Gemini 2.0 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D\n<img width=\"709\" height=\"880\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b\"\n/>\n\n- Gemini 2.5 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D\n<img width=\"708\" height=\"872\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061\"\n/>\n\n\n### Checklist\n\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"021b30816e86ddb2e1fa2a8c911ff85ab07e1d43","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Obs AI Assistant","ci:project-deploy-observability","backport:version","v9.1.0","v8.19.0","v9.2.0","v8.18.4","v9.0.4"],"title":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked","number":227462,"url":"https://github.com/elastic/kibana/pull/227462","mergeCommit":{"message":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/309\n\n## Summary\n\nThis PR improves the `Display Results` and `visualize this query`\nactions by injecting a user prompt first and then the tool call to\nmaintain correct message ordering. This fixes the empty message that was\nobserved when visualize this query was clicked.\n\nHowever, in any case, if an empty message is received this should be\nhandled separately to avoid breaking the conversation flow.\n\n## Testing instructions:\n1. Generate some logs\n2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude\n3.5, Claude 3.7, GPT-4, etc)\n3. Ask the assistant to generate a query\n4. Click on `Display results` -- the results should be shown and the\nuser should be able to continue the conversation\n5. Click on `Visualize this query` -- the visualization should be shown\nand the user should be able to continue the conversation\n\n## Traces with each model:\n\n- EIS (Visualize this query) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D\n<img width=\"715\" height=\"868\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da\"\n/>\n\n- EIS (Display results) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D\n\n\nhttps://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669\n\n- Bedrock+Claude 3.7 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D\n<img width=\"709\" height=\"889\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227\"\n/>\n\n\n- Bedrock+Claude 3.5 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D\n<img width=\"714\" height=\"942\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139\"\n/>\n\n\n- AzureOpenAI+GPT 4.1 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D\n<img width=\"715\" height=\"877\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d\"\n/>\n\n\n- Gemini 2.0 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D\n<img width=\"709\" height=\"880\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b\"\n/>\n\n- Gemini 2.5 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D\n<img width=\"708\" height=\"872\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061\"\n/>\n\n\n### Checklist\n\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"021b30816e86ddb2e1fa2a8c911ff85ab07e1d43"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19","8.18","9.0"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/227462","number":227462,"mergeCommit":{"message":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/309\n\n## Summary\n\nThis PR improves the `Display Results` and `visualize this query`\nactions by injecting a user prompt first and then the tool call to\nmaintain correct message ordering. This fixes the empty message that was\nobserved when visualize this query was clicked.\n\nHowever, in any case, if an empty message is received this should be\nhandled separately to avoid breaking the conversation flow.\n\n## Testing instructions:\n1. Generate some logs\n2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude\n3.5, Claude 3.7, GPT-4, etc)\n3. Ask the assistant to generate a query\n4. Click on `Display results` -- the results should be shown and the\nuser should be able to continue the conversation\n5. Click on `Visualize this query` -- the visualization should be shown\nand the user should be able to continue the conversation\n\n## Traces with each model:\n\n- EIS (Visualize this query) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D\n<img width=\"715\" height=\"868\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da\"\n/>\n\n- EIS (Display results) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D\n\n\nhttps://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669\n\n- Bedrock+Claude 3.7 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D\n<img width=\"709\" height=\"889\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227\"\n/>\n\n\n- Bedrock+Claude 3.5 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D\n<img width=\"714\" height=\"942\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139\"\n/>\n\n\n- AzureOpenAI+GPT 4.1 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D\n<img width=\"715\" height=\"877\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d\"\n/>\n\n\n- Gemini 2.0 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D\n<img width=\"709\" height=\"880\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b\"\n/>\n\n- Gemini 2.5 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D\n<img width=\"708\" height=\"872\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061\"\n/>\n\n\n### Checklist\n\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"021b30816e86ddb2e1fa2a8c911ff85ab07e1d43"}},{"branch":"8.18","label":"v8.18.4","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.4","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Viduni Wickramarachchi <viduni.wickramarachchi@elastic.co>
…ry actions are clicked (#227462) (#227643) # Backport This will backport the following commits from `main` to `9.1`: - [[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)](#227462) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Viduni Wickramarachchi","email":"viduni.wickramarachchi@elastic.co"},"sourceCommit":{"committedDate":"2025-07-11T12:25:04Z","message":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/309\n\n## Summary\n\nThis PR improves the `Display Results` and `visualize this query`\nactions by injecting a user prompt first and then the tool call to\nmaintain correct message ordering. This fixes the empty message that was\nobserved when visualize this query was clicked.\n\nHowever, in any case, if an empty message is received this should be\nhandled separately to avoid breaking the conversation flow.\n\n## Testing instructions:\n1. Generate some logs\n2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude\n3.5, Claude 3.7, GPT-4, etc)\n3. Ask the assistant to generate a query\n4. Click on `Display results` -- the results should be shown and the\nuser should be able to continue the conversation\n5. Click on `Visualize this query` -- the visualization should be shown\nand the user should be able to continue the conversation\n\n## Traces with each model:\n\n- EIS (Visualize this query) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D\n<img width=\"715\" height=\"868\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da\"\n/>\n\n- EIS (Display results) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D\n\n\nhttps://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669\n\n- Bedrock+Claude 3.7 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D\n<img width=\"709\" height=\"889\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227\"\n/>\n\n\n- Bedrock+Claude 3.5 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D\n<img width=\"714\" height=\"942\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139\"\n/>\n\n\n- AzureOpenAI+GPT 4.1 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D\n<img width=\"715\" height=\"877\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d\"\n/>\n\n\n- Gemini 2.0 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D\n<img width=\"709\" height=\"880\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b\"\n/>\n\n- Gemini 2.5 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D\n<img width=\"708\" height=\"872\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061\"\n/>\n\n\n### Checklist\n\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"021b30816e86ddb2e1fa2a8c911ff85ab07e1d43","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Obs AI Assistant","ci:project-deploy-observability","backport:version","v9.1.0","v8.19.0","v9.2.0","v8.18.4","v9.0.4"],"title":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked","number":227462,"url":"https://github.com/elastic/kibana/pull/227462","mergeCommit":{"message":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/309\n\n## Summary\n\nThis PR improves the `Display Results` and `visualize this query`\nactions by injecting a user prompt first and then the tool call to\nmaintain correct message ordering. This fixes the empty message that was\nobserved when visualize this query was clicked.\n\nHowever, in any case, if an empty message is received this should be\nhandled separately to avoid breaking the conversation flow.\n\n## Testing instructions:\n1. Generate some logs\n2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude\n3.5, Claude 3.7, GPT-4, etc)\n3. Ask the assistant to generate a query\n4. Click on `Display results` -- the results should be shown and the\nuser should be able to continue the conversation\n5. Click on `Visualize this query` -- the visualization should be shown\nand the user should be able to continue the conversation\n\n## Traces with each model:\n\n- EIS (Visualize this query) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D\n<img width=\"715\" height=\"868\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da\"\n/>\n\n- EIS (Display results) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D\n\n\nhttps://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669\n\n- Bedrock+Claude 3.7 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D\n<img width=\"709\" height=\"889\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227\"\n/>\n\n\n- Bedrock+Claude 3.5 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D\n<img width=\"714\" height=\"942\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139\"\n/>\n\n\n- AzureOpenAI+GPT 4.1 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D\n<img width=\"715\" height=\"877\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d\"\n/>\n\n\n- Gemini 2.0 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D\n<img width=\"709\" height=\"880\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b\"\n/>\n\n- Gemini 2.5 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D\n<img width=\"708\" height=\"872\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061\"\n/>\n\n\n### Checklist\n\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"021b30816e86ddb2e1fa2a8c911ff85ab07e1d43"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19","8.18","9.0"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/227462","number":227462,"mergeCommit":{"message":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/309\n\n## Summary\n\nThis PR improves the `Display Results` and `visualize this query`\nactions by injecting a user prompt first and then the tool call to\nmaintain correct message ordering. This fixes the empty message that was\nobserved when visualize this query was clicked.\n\nHowever, in any case, if an empty message is received this should be\nhandled separately to avoid breaking the conversation flow.\n\n## Testing instructions:\n1. Generate some logs\n2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude\n3.5, Claude 3.7, GPT-4, etc)\n3. Ask the assistant to generate a query\n4. Click on `Display results` -- the results should be shown and the\nuser should be able to continue the conversation\n5. Click on `Visualize this query` -- the visualization should be shown\nand the user should be able to continue the conversation\n\n## Traces with each model:\n\n- EIS (Visualize this query) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D\n<img width=\"715\" height=\"868\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da\"\n/>\n\n- EIS (Display results) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D\n\n\nhttps://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669\n\n- Bedrock+Claude 3.7 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D\n<img width=\"709\" height=\"889\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227\"\n/>\n\n\n- Bedrock+Claude 3.5 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D\n<img width=\"714\" height=\"942\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139\"\n/>\n\n\n- AzureOpenAI+GPT 4.1 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D\n<img width=\"715\" height=\"877\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d\"\n/>\n\n\n- Gemini 2.0 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D\n<img width=\"709\" height=\"880\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b\"\n/>\n\n- Gemini 2.5 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D\n<img width=\"708\" height=\"872\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061\"\n/>\n\n\n### Checklist\n\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"021b30816e86ddb2e1fa2a8c911ff85ab07e1d43"}},{"branch":"8.18","label":"v8.18.4","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.4","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Viduni Wickramarachchi <viduni.wickramarachchi@elastic.co>
…ry actions are clicked (#227462) (#227642) # Backport This will backport the following commits from `main` to `9.0`: - [[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)](#227462) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Viduni Wickramarachchi","email":"viduni.wickramarachchi@elastic.co"},"sourceCommit":{"committedDate":"2025-07-11T12:25:04Z","message":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/309\n\n## Summary\n\nThis PR improves the `Display Results` and `visualize this query`\nactions by injecting a user prompt first and then the tool call to\nmaintain correct message ordering. This fixes the empty message that was\nobserved when visualize this query was clicked.\n\nHowever, in any case, if an empty message is received this should be\nhandled separately to avoid breaking the conversation flow.\n\n## Testing instructions:\n1. Generate some logs\n2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude\n3.5, Claude 3.7, GPT-4, etc)\n3. Ask the assistant to generate a query\n4. Click on `Display results` -- the results should be shown and the\nuser should be able to continue the conversation\n5. Click on `Visualize this query` -- the visualization should be shown\nand the user should be able to continue the conversation\n\n## Traces with each model:\n\n- EIS (Visualize this query) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D\n<img width=\"715\" height=\"868\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da\"\n/>\n\n- EIS (Display results) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D\n\n\nhttps://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669\n\n- Bedrock+Claude 3.7 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D\n<img width=\"709\" height=\"889\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227\"\n/>\n\n\n- Bedrock+Claude 3.5 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D\n<img width=\"714\" height=\"942\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139\"\n/>\n\n\n- AzureOpenAI+GPT 4.1 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D\n<img width=\"715\" height=\"877\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d\"\n/>\n\n\n- Gemini 2.0 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D\n<img width=\"709\" height=\"880\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b\"\n/>\n\n- Gemini 2.5 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D\n<img width=\"708\" height=\"872\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061\"\n/>\n\n\n### Checklist\n\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"021b30816e86ddb2e1fa2a8c911ff85ab07e1d43","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Obs AI Assistant","ci:project-deploy-observability","backport:version","v9.1.0","v8.19.0","v9.2.0","v8.18.4","v9.0.4"],"title":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked","number":227462,"url":"https://github.com/elastic/kibana/pull/227462","mergeCommit":{"message":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/309\n\n## Summary\n\nThis PR improves the `Display Results` and `visualize this query`\nactions by injecting a user prompt first and then the tool call to\nmaintain correct message ordering. This fixes the empty message that was\nobserved when visualize this query was clicked.\n\nHowever, in any case, if an empty message is received this should be\nhandled separately to avoid breaking the conversation flow.\n\n## Testing instructions:\n1. Generate some logs\n2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude\n3.5, Claude 3.7, GPT-4, etc)\n3. Ask the assistant to generate a query\n4. Click on `Display results` -- the results should be shown and the\nuser should be able to continue the conversation\n5. Click on `Visualize this query` -- the visualization should be shown\nand the user should be able to continue the conversation\n\n## Traces with each model:\n\n- EIS (Visualize this query) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D\n<img width=\"715\" height=\"868\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da\"\n/>\n\n- EIS (Display results) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D\n\n\nhttps://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669\n\n- Bedrock+Claude 3.7 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D\n<img width=\"709\" height=\"889\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227\"\n/>\n\n\n- Bedrock+Claude 3.5 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D\n<img width=\"714\" height=\"942\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139\"\n/>\n\n\n- AzureOpenAI+GPT 4.1 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D\n<img width=\"715\" height=\"877\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d\"\n/>\n\n\n- Gemini 2.0 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D\n<img width=\"709\" height=\"880\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b\"\n/>\n\n- Gemini 2.5 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D\n<img width=\"708\" height=\"872\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061\"\n/>\n\n\n### Checklist\n\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"021b30816e86ddb2e1fa2a8c911ff85ab07e1d43"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19","8.18","9.0"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/227462","number":227462,"mergeCommit":{"message":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/309\n\n## Summary\n\nThis PR improves the `Display Results` and `visualize this query`\nactions by injecting a user prompt first and then the tool call to\nmaintain correct message ordering. This fixes the empty message that was\nobserved when visualize this query was clicked.\n\nHowever, in any case, if an empty message is received this should be\nhandled separately to avoid breaking the conversation flow.\n\n## Testing instructions:\n1. Generate some logs\n2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude\n3.5, Claude 3.7, GPT-4, etc)\n3. Ask the assistant to generate a query\n4. Click on `Display results` -- the results should be shown and the\nuser should be able to continue the conversation\n5. Click on `Visualize this query` -- the visualization should be shown\nand the user should be able to continue the conversation\n\n## Traces with each model:\n\n- EIS (Visualize this query) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D\n<img width=\"715\" height=\"868\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da\"\n/>\n\n- EIS (Display results) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D\n\n\nhttps://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669\n\n- Bedrock+Claude 3.7 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D\n<img width=\"709\" height=\"889\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227\"\n/>\n\n\n- Bedrock+Claude 3.5 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D\n<img width=\"714\" height=\"942\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139\"\n/>\n\n\n- AzureOpenAI+GPT 4.1 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D\n<img width=\"715\" height=\"877\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d\"\n/>\n\n\n- Gemini 2.0 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D\n<img width=\"709\" height=\"880\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b\"\n/>\n\n- Gemini 2.5 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D\n<img width=\"708\" height=\"872\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061\"\n/>\n\n\n### Checklist\n\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"021b30816e86ddb2e1fa2a8c911ff85ab07e1d43"}},{"branch":"8.18","label":"v8.18.4","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.4","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Viduni Wickramarachchi <viduni.wickramarachchi@elastic.co>
…ery actions are clicked (#227462) (#227649) # Backport This will backport the following commits from `main` to `8.18`: - [[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)](#227462) <!--- Backport version: 10.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Viduni Wickramarachchi","email":"viduni.wickramarachchi@elastic.co"},"sourceCommit":{"committedDate":"2025-07-11T12:25:04Z","message":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/309\n\n## Summary\n\nThis PR improves the `Display Results` and `visualize this query`\nactions by injecting a user prompt first and then the tool call to\nmaintain correct message ordering. This fixes the empty message that was\nobserved when visualize this query was clicked.\n\nHowever, in any case, if an empty message is received this should be\nhandled separately to avoid breaking the conversation flow.\n\n## Testing instructions:\n1. Generate some logs\n2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude\n3.5, Claude 3.7, GPT-4, etc)\n3. Ask the assistant to generate a query\n4. Click on `Display results` -- the results should be shown and the\nuser should be able to continue the conversation\n5. Click on `Visualize this query` -- the visualization should be shown\nand the user should be able to continue the conversation\n\n## Traces with each model:\n\n- EIS (Visualize this query) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D\n<img width=\"715\" height=\"868\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da\"\n/>\n\n- EIS (Display results) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D\n\n\nhttps://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669\n\n- Bedrock+Claude 3.7 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D\n<img width=\"709\" height=\"889\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227\"\n/>\n\n\n- Bedrock+Claude 3.5 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D\n<img width=\"714\" height=\"942\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139\"\n/>\n\n\n- AzureOpenAI+GPT 4.1 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D\n<img width=\"715\" height=\"877\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d\"\n/>\n\n\n- Gemini 2.0 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D\n<img width=\"709\" height=\"880\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b\"\n/>\n\n- Gemini 2.5 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D\n<img width=\"708\" height=\"872\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061\"\n/>\n\n\n### Checklist\n\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"021b30816e86ddb2e1fa2a8c911ff85ab07e1d43","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Obs AI Assistant","ci:project-deploy-observability","backport:version","v9.1.0","v8.19.0","v9.2.0","v8.18.4","v9.0.4"],"title":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked","number":227462,"url":"https://github.com/elastic/kibana/pull/227462","mergeCommit":{"message":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/309\n\n## Summary\n\nThis PR improves the `Display Results` and `visualize this query`\nactions by injecting a user prompt first and then the tool call to\nmaintain correct message ordering. This fixes the empty message that was\nobserved when visualize this query was clicked.\n\nHowever, in any case, if an empty message is received this should be\nhandled separately to avoid breaking the conversation flow.\n\n## Testing instructions:\n1. Generate some logs\n2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude\n3.5, Claude 3.7, GPT-4, etc)\n3. Ask the assistant to generate a query\n4. Click on `Display results` -- the results should be shown and the\nuser should be able to continue the conversation\n5. Click on `Visualize this query` -- the visualization should be shown\nand the user should be able to continue the conversation\n\n## Traces with each model:\n\n- EIS (Visualize this query) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D\n<img width=\"715\" height=\"868\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da\"\n/>\n\n- EIS (Display results) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D\n\n\nhttps://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669\n\n- Bedrock+Claude 3.7 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D\n<img width=\"709\" height=\"889\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227\"\n/>\n\n\n- Bedrock+Claude 3.5 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D\n<img width=\"714\" height=\"942\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139\"\n/>\n\n\n- AzureOpenAI+GPT 4.1 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D\n<img width=\"715\" height=\"877\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d\"\n/>\n\n\n- Gemini 2.0 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D\n<img width=\"709\" height=\"880\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b\"\n/>\n\n- Gemini 2.5 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D\n<img width=\"708\" height=\"872\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061\"\n/>\n\n\n### Checklist\n\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"021b30816e86ddb2e1fa2a8c911ff85ab07e1d43"}},"sourceBranch":"main","suggestedTargetBranches":["8.18"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/227643","number":227643,"state":"OPEN"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/227641","number":227641,"state":"OPEN"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/227462","number":227462,"mergeCommit":{"message":"[Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)\n\nCloses https://github.com/elastic/obs-ai-assistant-team/issues/309\n\n## Summary\n\nThis PR improves the `Display Results` and `visualize this query`\nactions by injecting a user prompt first and then the tool call to\nmaintain correct message ordering. This fixes the empty message that was\nobserved when visualize this query was clicked.\n\nHowever, in any case, if an empty message is received this should be\nhandled separately to avoid breaking the conversation flow.\n\n## Testing instructions:\n1. Generate some logs\n2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude\n3.5, Claude 3.7, GPT-4, etc)\n3. Ask the assistant to generate a query\n4. Click on `Display results` -- the results should be shown and the\nuser should be able to continue the conversation\n5. Click on `Visualize this query` -- the visualization should be shown\nand the user should be able to continue the conversation\n\n## Traces with each model:\n\n- EIS (Visualize this query) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D\n<img width=\"715\" height=\"868\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da\"\n/>\n\n- EIS (Display results) -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D\n\n\nhttps://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669\n\n- Bedrock+Claude 3.7 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D\n<img width=\"709\" height=\"889\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227\"\n/>\n\n\n- Bedrock+Claude 3.5 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D\n<img width=\"714\" height=\"942\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139\"\n/>\n\n\n- AzureOpenAI+GPT 4.1 -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D\n<img width=\"715\" height=\"877\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d\"\n/>\n\n\n- Gemini 2.0 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D\n<img width=\"709\" height=\"880\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b\"\n/>\n\n- Gemini 2.5 Flash -\nhttps://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D\n<img width=\"708\" height=\"872\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061\"\n/>\n\n\n### Checklist\n\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"021b30816e86ddb2e1fa2a8c911ff85ab07e1d43"}},{"branch":"8.18","label":"v8.18.4","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.4","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/227642","number":227642,"state":"OPEN"}]}] BACKPORT--> --------- Co-authored-by: Brad White <Ikuni17@users.noreply.github.com>
…ions are clicked (elastic#227462) Closes elastic/obs-ai-team#309 ## Summary This PR improves the `Display Results` and `visualize this query` actions by injecting a user prompt first and then the tool call to maintain correct message ordering. This fixes the empty message that was observed when visualize this query was clicked. However, in any case, if an empty message is received this should be handled separately to avoid breaking the conversation flow. ## Testing instructions: 1. Generate some logs 2. Pick the LLM (Needs to be tested with Elastic Managed LLM, Claude 3.5, Claude 3.7, GPT-4, etc) 3. Ask the assistant to generate a query 4. Click on `Display results` -- the results should be shown and the user should be able to continue the conversation 5. Click on `Visualize this query` -- the visualization should be shown and the user should be able to continue the conversation ## Traces with each model: - EIS (Visualize this query) - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/b1dcb77fb39ad7efbf82d9c4a1feb0e0?selectedSpanNodeId=U3BhbjoyOTk3ODQ%3D <img width="715" height="868" alt="image" src="https://github.com/user-attachments/assets/75fd8efe-82df-4f7f-ad4f-f915e09d49da" /> - EIS (Display results) - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/e7d8c42774491e6e2bcf328c34203c14?selectedSpanNodeId=U3BhbjozMDAxOTg%3D https://github.com/user-attachments/assets/6aa520db-2b40-4317-ace0-7be206ebb669 - Bedrock+Claude 3.7 - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/f1bc4f490fcc990db9dbddf0782cff7e?selectedSpanNodeId=U3BhbjoyOTk4MDA%3D <img width="709" height="889" alt="image" src="https://github.com/user-attachments/assets/86f77ff9-1783-42d3-8b31-8680fd7da227" /> - Bedrock+Claude 3.5 - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/457a7cc939ce3b18ae3a9e2b066c3a7f?selectedSpanNodeId=U3BhbjoyOTk4MTY%3D <img width="714" height="942" alt="image" src="https://github.com/user-attachments/assets/fe96b72e-24d0-4a85-9b42-a9862bdf4139" /> - AzureOpenAI+GPT 4.1 - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/de9fc09a6f0162b7b2d6f52fbb188469?selectedSpanNodeId=U3BhbjoyOTk4MzI%3D <img width="715" height="877" alt="image" src="https://github.com/user-attachments/assets/cca5326e-9350-426f-9f2e-a407d26e193d" /> - Gemini 2.0 Flash - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/982da6b0ff4bae04f45af0271aa4cd84?selectedSpanNodeId=U3BhbjoyOTk4NTI%3D <img width="709" height="880" alt="image" src="https://github.com/user-attachments/assets/d29b99c7-e3f6-4318-a19b-0a92e7aa690b" /> - Gemini 2.5 Flash - https://35-187-109-62.sslip.io/projects/UHJvamVjdDo5/traces/9f7115cc79bb2e929dbeb93670555e81?selectedSpanNodeId=U3BhbjoyOTk4NjU%3D <img width="708" height="872" alt="image" src="https://github.com/user-attachments/assets/4c6e48fd-ccaf-413c-b01d-21c0fc8df061" /> ### Checklist - [x] 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) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels.
Closes https://github.com/elastic/obs-ai-assistant-team/issues/309
Summary
This PR improves the
Display Resultsandvisualize this queryactions by injecting a user prompt first and then the tool call to maintain correct message ordering. This fixes the empty message that was observed when visualize this query was clicked.However, in any case, if an empty message is received this should be handled separately to avoid breaking the conversation flow.
Testing instructions:
Display results-- the results should be shown and the user should be able to continue the conversationVisualize this query-- the visualization should be shown and the user should be able to continue the conversationTraces with each model:
Screen.Recording.2025-07-10.at.1.17.47.PM.mov
Checklist
release_note:*label is applied per the guidelinesbackport:*labels.