Skip to content

Fix observability_ai_assistant_tool_call EBT error when connector is an inference endpoint#263334

Merged
yuliia-fryshko merged 14 commits intoelastic:mainfrom
yuliia-fryshko:fix-observability-ai-assistant-tool-call-ebt
Apr 19, 2026
Merged

Fix observability_ai_assistant_tool_call EBT error when connector is an inference endpoint#263334
yuliia-fryshko merged 14 commits intoelastic:mainfrom
yuliia-fryshko:fix-observability-ai-assistant-tool-call-ebt

Conversation

@yuliia-fryshko
Copy link
Copy Markdown
Contributor

@yuliia-fryshko yuliia-fryshko commented Apr 15, 2026

Closes https://github.com/elastic/obs-ai-team/issues/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\"}"}

@yuliia-fryshko yuliia-fryshko self-assigned this Apr 15, 2026
@yuliia-fryshko yuliia-fryshko added the release_note:skip Skip the PR/issue when compiling release notes label Apr 15, 2026
@yuliia-fryshko yuliia-fryshko requested a review from a team as a code owner April 15, 2026 09:34
@yuliia-fryshko yuliia-fryshko added backport:version Backport to applied version labels v9.4.0 labels Apr 15, 2026
@botelastic botelastic Bot added ci:project-deploy-observability Create an Observability project Team:obs-ai Observability AI team labels Apr 15, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/obs-ai-team (Team:obs-ai)

@github-actions
Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

InferenceClient,
} from '@kbn/inference-common';
import { ToolChoiceType } from '@kbn/inference-common';
import { getConnectorByIdWithoutClientRequest } from '@kbn/inference-plugin/server/util/get_connector_by_id';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(..)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we adding this check? Isn't connectorInfo returned even when inference endpoints are used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We pass connector? as optional. That’s why, when it’s undefined, the inference connector returns undefined as well .

Copy link
Copy Markdown
Contributor

@viduni94 viduni94 Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

yuliia-fryshko and others added 4 commits April 17, 2026 11:51
simulateFunctionCalling: boolean;
analytics: AnalyticsServiceStart;
connector?: Connector;
connector?: InferenceConnectorType;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct?
Or should it be InferenceConnector?

Comment on lines 285 to 301
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()
)
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Contributor

@viduni94 viduni94 Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

yuliia-fryshko and others added 2 commits April 17, 2026 17:32
Co-authored-by: Viduni Wickramarachchi <viduni.ushanka@gmail.com>
scopes: ['all'],
})
);
expect(mockAnalytics.reportEvent).not.toHaveBeenCalled();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test should be restored to the previous

@elasticmachine

This comment was marked as outdated.

@elastic-vault-github-plugin-prod
Copy link
Copy Markdown
Contributor

Run Metadata

  • Triggered by: Issue #220
  • Elasticsearch image tag: 9.4.0-SNAPSHOT
  • Kibana image: docker.elastic.co/kibana-ci/kibana-serverless:pr-263334-787c7fad8ccc
  • Date: 2026-04-18
  • PR: elastic/kibana#263334 — Fix observability_ai_assistant_tool_call EBT error when connector is an inference endpoint
  • Mode: PR-targeted (journeys generated from PR diff)
  • Journeys executed: 8
  • Passed: 8
  • Errored: 0
  • Findings: 0 bugs, 0 warnings, 0 info

Findings

No findings -- all journeys completed without issues.


Screenshots

Screenshots are available in the workflow artifacts.


Workflow run: https://github.com/elastic/kibana-exploratory-testing/actions/runs/24592831729

@yuliia-fryshko yuliia-fryshko merged commit d0e1774 into elastic:main Apr 19, 2026
18 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 9.4

https://github.com/elastic/kibana/actions/runs/24632273392

kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Apr 19, 2026
…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)
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
9.4

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kapral18 added a commit to kapral18/kibana that referenced this pull request Apr 19, 2026
* 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)
  ...
kibanamachine added a commit that referenced this pull request Apr 20, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels ci:project-deploy-observability Create an Observability project release_note:skip Skip the PR/issue when compiling release notes Team:obs-ai Observability AI team v9.4.0 v9.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants