Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [Obs AI Assistant] Include an AdHoc instruction about the slack…
… connector to avoid executing a loop (#199531) (#199860) # Backport This will backport the following commits from `main` to `8.x`: - [[Obs AI Assistant] Include an AdHoc instruction about the slack connector to avoid executing a loop (#199531)](#199531) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Viduni Wickramarachchi","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-12T18:28:08Z","message":"[Obs AI Assistant] Include an AdHoc instruction about the slack connector to avoid executing a loop (#199531)\n\nCloses https://github.com/elastic/kibana/issues/185028\r\n\r\n## Summary\r\n\r\n### Problem\r\nThe ticket mentions that there was an issue with displaying results.\r\nHowever both `display results` and `visualize query` are working as\r\nexpected based on my investigation. More details including a video are\r\nattached\r\n[here](https://github.com/elastic/kibana/issues/185028#issuecomment-2464879452).\r\n\r\nThe function calling loop seems to occur when the AI Assistant is trying\r\nto send the output to Slack via the Kibana Slack connector. In order to\r\ndo this, the LLM invokes the function `execute_connector`. For the Slack\r\nconnector, `id` and `params` properties are required. However, the LLM\r\nonly populated `id` and not `params` which causes an error when\r\nvalidated against the schema for the Slack connector.\r\n\r\n- Sometimes, it's able to retry a few times and successfully send the\r\noutput to Slack.\r\n- Sometimes, it goes into a loop trying to find `params` and failing\r\nrepeatedly.\r\n\r\nAttaching another similar issue for more context -\r\nhttps://github.com//issues/195564\r\n\r\n_With the solution below, my intention is to send the output to Slack in\r\none go, without retrying the function `execute_connector`._\r\n\r\n### Solution\r\nBased on the solutions I experimented with, seems like we need to force\r\nthe LLM to understand what's needed for the Slack connector. I tried a\r\nfew options here and the combination of updates that worked are as\r\nfollows:\r\n- Appending an AdHoc instruction about the Slack connector properties.\r\n(This gives the LLM some additional information about the required\r\nproperties)\r\n- Updating the `properties` attached to the connector (when passing the\r\nconnector list to the LLM), to reflect both `id` and `params` with\r\n`message`.\r\n\r\nWith the above change, the AI Assistant has managed to consistently send\r\nthe output to Slack _**without any retries**_ because of missing\r\n`params`.\r\n\r\n### Screenshots:\r\n(all alert triggers successfully sent the output to Slack without having\r\nto retry the function)\r\n\r\n<img width=\"1452\" alt=\"success-attempts-to-slack-connector\"\r\nsrc=\"https://github.com/user-attachments/assets/715a5957-2c04-4a55-868f-34abe564f6d4\">","sha":"ed4c0df9ee304ea9bc71ed30c8e5dc2dd9295a00","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","Team:Obs AI Assistant","ci:project-deploy-observability","backport:version","v8.17.0"],"title":"[Obs AI Assistant] Include an AdHoc instruction about the slack connector to avoid executing a loop","number":199531,"url":"https://github.com/elastic/kibana/pull/199531","mergeCommit":{"message":"[Obs AI Assistant] Include an AdHoc instruction about the slack connector to avoid executing a loop (#199531)\n\nCloses https://github.com/elastic/kibana/issues/185028\r\n\r\n## Summary\r\n\r\n### Problem\r\nThe ticket mentions that there was an issue with displaying results.\r\nHowever both `display results` and `visualize query` are working as\r\nexpected based on my investigation. More details including a video are\r\nattached\r\n[here](https://github.com/elastic/kibana/issues/185028#issuecomment-2464879452).\r\n\r\nThe function calling loop seems to occur when the AI Assistant is trying\r\nto send the output to Slack via the Kibana Slack connector. In order to\r\ndo this, the LLM invokes the function `execute_connector`. For the Slack\r\nconnector, `id` and `params` properties are required. However, the LLM\r\nonly populated `id` and not `params` which causes an error when\r\nvalidated against the schema for the Slack connector.\r\n\r\n- Sometimes, it's able to retry a few times and successfully send the\r\noutput to Slack.\r\n- Sometimes, it goes into a loop trying to find `params` and failing\r\nrepeatedly.\r\n\r\nAttaching another similar issue for more context -\r\nhttps://github.com//issues/195564\r\n\r\n_With the solution below, my intention is to send the output to Slack in\r\none go, without retrying the function `execute_connector`._\r\n\r\n### Solution\r\nBased on the solutions I experimented with, seems like we need to force\r\nthe LLM to understand what's needed for the Slack connector. I tried a\r\nfew options here and the combination of updates that worked are as\r\nfollows:\r\n- Appending an AdHoc instruction about the Slack connector properties.\r\n(This gives the LLM some additional information about the required\r\nproperties)\r\n- Updating the `properties` attached to the connector (when passing the\r\nconnector list to the LLM), to reflect both `id` and `params` with\r\n`message`.\r\n\r\nWith the above change, the AI Assistant has managed to consistently send\r\nthe output to Slack _**without any retries**_ because of missing\r\n`params`.\r\n\r\n### Screenshots:\r\n(all alert triggers successfully sent the output to Slack without having\r\nto retry the function)\r\n\r\n<img width=\"1452\" alt=\"success-attempts-to-slack-connector\"\r\nsrc=\"https://github.com/user-attachments/assets/715a5957-2c04-4a55-868f-34abe564f6d4\">","sha":"ed4c0df9ee304ea9bc71ed30c8e5dc2dd9295a00"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/199531","number":199531,"mergeCommit":{"message":"[Obs AI Assistant] Include an AdHoc instruction about the slack connector to avoid executing a loop (#199531)\n\nCloses https://github.com/elastic/kibana/issues/185028\r\n\r\n## Summary\r\n\r\n### Problem\r\nThe ticket mentions that there was an issue with displaying results.\r\nHowever both `display results` and `visualize query` are working as\r\nexpected based on my investigation. More details including a video are\r\nattached\r\n[here](https://github.com/elastic/kibana/issues/185028#issuecomment-2464879452).\r\n\r\nThe function calling loop seems to occur when the AI Assistant is trying\r\nto send the output to Slack via the Kibana Slack connector. In order to\r\ndo this, the LLM invokes the function `execute_connector`. For the Slack\r\nconnector, `id` and `params` properties are required. However, the LLM\r\nonly populated `id` and not `params` which causes an error when\r\nvalidated against the schema for the Slack connector.\r\n\r\n- Sometimes, it's able to retry a few times and successfully send the\r\noutput to Slack.\r\n- Sometimes, it goes into a loop trying to find `params` and failing\r\nrepeatedly.\r\n\r\nAttaching another similar issue for more context -\r\nhttps://github.com//issues/195564\r\n\r\n_With the solution below, my intention is to send the output to Slack in\r\none go, without retrying the function `execute_connector`._\r\n\r\n### Solution\r\nBased on the solutions I experimented with, seems like we need to force\r\nthe LLM to understand what's needed for the Slack connector. I tried a\r\nfew options here and the combination of updates that worked are as\r\nfollows:\r\n- Appending an AdHoc instruction about the Slack connector properties.\r\n(This gives the LLM some additional information about the required\r\nproperties)\r\n- Updating the `properties` attached to the connector (when passing the\r\nconnector list to the LLM), to reflect both `id` and `params` with\r\n`message`.\r\n\r\nWith the above change, the AI Assistant has managed to consistently send\r\nthe output to Slack _**without any retries**_ because of missing\r\n`params`.\r\n\r\n### Screenshots:\r\n(all alert triggers successfully sent the output to Slack without having\r\nto retry the function)\r\n\r\n<img width=\"1452\" alt=\"success-attempts-to-slack-connector\"\r\nsrc=\"https://github.com/user-attachments/assets/715a5957-2c04-4a55-868f-34abe564f6d4\">","sha":"ed4c0df9ee304ea9bc71ed30c8e5dc2dd9295a00"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Viduni Wickramarachchi <[email protected]>
- Loading branch information