Fix observability_ai_assistant_tool_call EBT error when connector is an inference endpoint#263334
Conversation
…an inference endpoint
|
Pinging @elastic/obs-ai-team (Team:obs-ai) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
| InferenceClient, | ||
| } from '@kbn/inference-common'; | ||
| import { ToolChoiceType } from '@kbn/inference-common'; | ||
| import { getConnectorByIdWithoutClientRequest } from '@kbn/inference-plugin/server/util/get_connector_by_id'; |
There was a problem hiding this comment.
I don't think we should do a deep import like this to a inference plugin server util.
The getConnectorByIdWithoutClientRequest is exposed via the inference plugin's start contract (InferenceServerStart). We should add a dependancy to the start contract (if it doesn't exist already) and use this function via that:
await inference.getConnectorByIdWithoutClientRequest(..)
There was a problem hiding this comment.
Thanks, Viduni! I replaced the deep import from @kbn/inference-plugin/server/util/get_connector_by_id with a type import of InferenceServerStart from @kbn/inference-plugin/server
| scopes, | ||
| }); | ||
| const connectorInfo = getInferenceConnectorInfo(connector); | ||
| if (connectorInfo) { |
There was a problem hiding this comment.
Why are we adding this check? Isn't connectorInfo returned even when inference endpoints are used?
There was a problem hiding this comment.
We pass connector? as optional. That’s why, when it’s undefined, the inference connector returns undefined as well .
There was a problem hiding this comment.
Hmmm, I don't get it.. Shouldn't there be a valid connector to reach this point?
If the connector didn't exist, the chat() calls would fail long before any tool execution happens.
By adding this condition it masks a scenario that shouldn't happen silently and we wouldn't catch any regressions in the future like we did with this case after the inference feature registry changes.
The better approach is: since the connector must exist for the conversation to work, if getConnectorById fails it's an unexpected error worth logging, and the analytics event should still be reported (the toolName and scopes data is valuable regardless).
Therefore, I think this guard should be removed and the original unconditional reporting should be restored (The related test for this says "handles missing connector gracefully") . The real fix is already done via getConnectorById which correctly resolves inference endpoints, so connector won't be undefined in a normal operation.
Does that make sense?
There was a problem hiding this comment.
Yes, I agree that it would be better to remove this case, as it could hide some broken scenarios. I also believe that if there is no connector, it should fail earlier.
…er/service/client/operators/continue_conversation.ts Co-authored-by: Viduni Wickramarachchi <viduni.ushanka@gmail.com>
| simulateFunctionCalling: boolean; | ||
| analytics: AnalyticsServiceStart; | ||
| connector?: Connector; | ||
| connector?: InferenceConnectorType; |
There was a problem hiding this comment.
Is this correct?
Or should it be InferenceConnector?
| const connector$ = defer(() => | ||
| from( | ||
| this.dependencies.actionsClient.get({ | ||
| id: connectorId, | ||
| throwIfSystemAction: true, | ||
| }) | ||
| this.dependencies.inference.getConnectorByIdWithoutClientRequest( | ||
| connectorId, | ||
| this.dependencies.actionsClient, | ||
| this.dependencies.esClient.asInternalUser | ||
| ) | ||
| ).pipe( | ||
| catchError((error) => { | ||
| this.dependencies.logger.debug( | ||
| `Failed to fetch connector for analytics: ${error.message}` | ||
| ); | ||
| return of(undefined); | ||
| }), | ||
| shareReplay() | ||
| ) | ||
| ); |
There was a problem hiding this comment.
After adding https://github.com/elastic/kibana/pull/263334/changes#r3100903510 you could do:
const connector$ = defer(() =>
from(this.dependencies.getConnectorById(connectorId)).pipe(
catchError((error) => {
this.dependencies.logger.debug(
`Failed to fetch connector for analytics: ${error.message}`
);
return of(undefined);
}),
shareReplay()
)
);
| scopes, | ||
| }); | ||
| const connectorInfo = getInferenceConnectorInfo(connector); | ||
| if (connectorInfo) { |
There was a problem hiding this comment.
Hmmm, I don't get it.. Shouldn't there be a valid connector to reach this point?
If the connector didn't exist, the chat() calls would fail long before any tool execution happens.
By adding this condition it masks a scenario that shouldn't happen silently and we wouldn't catch any regressions in the future like we did with this case after the inference feature registry changes.
The better approach is: since the connector must exist for the conversation to work, if getConnectorById fails it's an unexpected error worth logging, and the analytics event should still be reported (the toolName and scopes data is valuable regardless).
Therefore, I think this guard should be removed and the original unconditional reporting should be restored (The related test for this says "handles missing connector gracefully") . The real fix is already done via getConnectorById which correctly resolves inference endpoints, so connector won't be undefined in a normal operation.
Does that make sense?
Co-authored-by: Viduni Wickramarachchi <viduni.ushanka@gmail.com>
| scopes: ['all'], | ||
| }) | ||
| ); | ||
| expect(mockAnalytics.reportEvent).not.toHaveBeenCalled(); |
There was a problem hiding this comment.
This test should be restored to the previous
This comment was marked as outdated.
This comment was marked as outdated.
Run Metadata
FindingsNo findings -- all journeys completed without issues. ScreenshotsScreenshots are available in the workflow artifacts. Workflow run: https://github.com/elastic/kibana-exploratory-testing/actions/runs/24592831729 |
|
Starting backport for target branches: 9.4 https://github.com/elastic/kibana/actions/runs/24632273392 |
…an inference endpoint (elastic#263334) Closes elastic/obs-ai-team#564 Replaced `actionsClient.get()` with `getConnectorByIdWithoutClientRequest()` from the inference plugin to resolve connector info for analytics. The old method only worked for traditional action connectors, not inference endpoints, causing the connector to be undefined and the EBT schema validation to fail. **Test Plan:** 1. Open Observability AI Assistant; 2. Ask any question, like "Do I have any alerts?" 3.Check that in the logs there is no errors like `"message": "Failed to validate payload coming from \"Event Type 'observability_ai_assistant_tool_call'\":\n\t- [connector]: {\"expected\":\"{ connectorId: string, name: string, type: string, modelFamily: string, modelProvider: string, modelId?: string }\",\"actual\":\"undefined\",\"value\":\"undefined\"}"}` --------- Co-authored-by: Viduni Wickramarachchi <viduni.ushanka@gmail.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit d0e1774)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
* main: (114 commits) Fix observability_ai_assistant_tool_call EBT error when connector is an inference endpoint (elastic#263334) init on install (elastic#263732) [One Workflow] fail-fast TaskRecovery for interrupted runs (elastic#261275) [Entity Store] Reset state error after successful task run (elastic#263087) [api-docs] 2026-04-19 Daily api_docs build (elastic#264280) [UII] Fix integration card row height calculation (elastic#264212) [scout] migrate FTR logstash api tests (elastic#262953) [StorageIndexAdapter] Set auto_expand_replicas to fix yellow health on single-node ES clusters (elastic#263096) [api-docs] 2026-04-18 Daily api_docs build (elastic#264260) [Scout] Update test config manifests (elastic#264257) [Security Solution][Detection Engine] enables AI rule creation feature flag (elastic#264036) [dashboards as code] only validate id on PUT route when creating new dashboard (elastic#264161) chore(NA): bump version to 9.5.0 (elastic#262165) skip failing test suite (elastic#263649) skip failing test suite (elastic#264236) [Discover] Convert remaining Enzyme tests to RTL (elastic#259676) auto-implement: Labels in model endpoints table of the model details flyout look misaligned (elastic#263770) [ci] Promote ES docker image after verification (elastic#263890) [Observability:Onboarding] Remove suppress global announcements that was breaking ensemble tests (elastic#264169) [Cases][AttachmentV2] Migrate persistable state part 2 - ML and AIOps charts (elastic#262597) ...
…or is an inference endpoint (#263334) (#264292) # Backport This will backport the following commits from `main` to `9.4`: - [Fix observability_ai_assistant_tool_call EBT error when connector is an inference endpoint (#263334)](#263334) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Yuliia Fryshko","email":"yuliia.fryshko@elastic.co"},"sourceCommit":{"committedDate":"2026-04-19T15:14:04Z","message":"Fix observability_ai_assistant_tool_call EBT error when connector is an inference endpoint (#263334)\n\nCloses https://github.com/elastic/obs-ai-team/issues/564\n\nReplaced `actionsClient.get()` with\n`getConnectorByIdWithoutClientRequest()` from the inference plugin to\nresolve connector info for analytics. The old method only worked for\ntraditional action connectors, not inference endpoints, causing the\nconnector to be undefined and the EBT schema validation to fail.\n\n\n**Test Plan:**\n\n1. Open Observability AI Assistant;\n2. Ask any question, like \"Do I have any alerts?\" \n3.Check that in the logs there is no errors like \n`\"message\": \"Failed to validate payload coming from \\\"Event Type\n'observability_ai_assistant_tool_call'\\\":\\n\\t- [connector]:\n{\\\"expected\\\":\\\"{ connectorId: string, name: string, type: string,\nmodelFamily: string, modelProvider: string, modelId?: string\n}\\\",\\\"actual\\\":\\\"undefined\\\",\\\"value\\\":\\\"undefined\\\"}\"}`\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <viduni.ushanka@gmail.com>\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"d0e17745ff0c0ffef006f8896ff83519f4ff8364","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","ci:project-deploy-observability","backport:version","Team:obs-ai","v9.4.0","v9.5.0"],"title":"Fix observability_ai_assistant_tool_call EBT error when connector is an inference endpoint","number":263334,"url":"https://github.com/elastic/kibana/pull/263334","mergeCommit":{"message":"Fix observability_ai_assistant_tool_call EBT error when connector is an inference endpoint (#263334)\n\nCloses https://github.com/elastic/obs-ai-team/issues/564\n\nReplaced `actionsClient.get()` with\n`getConnectorByIdWithoutClientRequest()` from the inference plugin to\nresolve connector info for analytics. The old method only worked for\ntraditional action connectors, not inference endpoints, causing the\nconnector to be undefined and the EBT schema validation to fail.\n\n\n**Test Plan:**\n\n1. Open Observability AI Assistant;\n2. Ask any question, like \"Do I have any alerts?\" \n3.Check that in the logs there is no errors like \n`\"message\": \"Failed to validate payload coming from \\\"Event Type\n'observability_ai_assistant_tool_call'\\\":\\n\\t- [connector]:\n{\\\"expected\\\":\\\"{ connectorId: string, name: string, type: string,\nmodelFamily: string, modelProvider: string, modelId?: string\n}\\\",\\\"actual\\\":\\\"undefined\\\",\\\"value\\\":\\\"undefined\\\"}\"}`\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <viduni.ushanka@gmail.com>\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"d0e17745ff0c0ffef006f8896ff83519f4ff8364"}},"sourceBranch":"main","suggestedTargetBranches":["9.4"],"targetPullRequestStates":[{"branch":"9.4","label":"v9.4.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/263334","number":263334,"mergeCommit":{"message":"Fix observability_ai_assistant_tool_call EBT error when connector is an inference endpoint (#263334)\n\nCloses https://github.com/elastic/obs-ai-team/issues/564\n\nReplaced `actionsClient.get()` with\n`getConnectorByIdWithoutClientRequest()` from the inference plugin to\nresolve connector info for analytics. The old method only worked for\ntraditional action connectors, not inference endpoints, causing the\nconnector to be undefined and the EBT schema validation to fail.\n\n\n**Test Plan:**\n\n1. Open Observability AI Assistant;\n2. Ask any question, like \"Do I have any alerts?\" \n3.Check that in the logs there is no errors like \n`\"message\": \"Failed to validate payload coming from \\\"Event Type\n'observability_ai_assistant_tool_call'\\\":\\n\\t- [connector]:\n{\\\"expected\\\":\\\"{ connectorId: string, name: string, type: string,\nmodelFamily: string, modelProvider: string, modelId?: string\n}\\\",\\\"actual\\\":\\\"undefined\\\",\\\"value\\\":\\\"undefined\\\"}\"}`\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <viduni.ushanka@gmail.com>\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"d0e17745ff0c0ffef006f8896ff83519f4ff8364"}}]}] BACKPORT--> Co-authored-by: Yuliia Fryshko <yuliia.fryshko@elastic.co> Co-authored-by: Viduni Wickramarachchi <viduni.ushanka@gmail.com>
Closes https://github.com/elastic/obs-ai-team/issues/564
Replaced
actionsClient.get()withgetConnectorByIdWithoutClientRequest()from the inference plugin to resolve connector info for analytics. The old method only worked for traditional action connectors, not inference endpoints, causing the connector to be undefined and the EBT schema validation to fail.Test Plan:
3.Check that in the logs there is no errors like
"message": "Failed to validate payload coming from \"Event Type 'observability_ai_assistant_tool_call'\":\n\t- [connector]: {\"expected\":\"{ connectorId: string, name: string, type: string, modelFamily: string, modelProvider: string, modelId?: string }\",\"actual\":\"undefined\",\"value\":\"undefined\"}"}