Skip to content

[9.0] [Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)#227642

Merged
kibanamachine merged 1 commit intoelastic:9.0from
kibanamachine:backport/9.0/pr-227462
Jul 11, 2025
Merged

[9.0] [Obs AI Assistant] Inject user prompt before tool call when query actions are clicked (#227462)#227642
kibanamachine merged 1 commit intoelastic:9.0from
kibanamachine:backport/9.0/pr-227462

Conversation

@kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 9.0:

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)
@kibanamachine kibanamachine added the backport This PR is a backport of another PR label Jul 11, 2025
@kibanamachine kibanamachine enabled auto-merge (squash) July 11, 2025 12:32
@kibanamachine kibanamachine merged commit 9efa88b into elastic:9.0 Jul 11, 2025
12 checks passed
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #26 / Agents fleet_list_agent should return metrics if available and called with withMetrics
  • [job] [logs] FTR Configs #33 / console app console onboarding tour allows re-running the tour

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 281.2KB 281.5KB +307.0B
searchAssistant 163.2KB 163.5KB +307.0B
total +614.0B

cc @viduni94

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants