Skip to content

[Inference] Move model resolution entirely to backend#263843

Merged
sphilipse merged 7 commits intoelastic:mainfrom
sphilipse:move-connectors-to-backend
Apr 17, 2026
Merged

[Inference] Move model resolution entirely to backend#263843
sphilipse merged 7 commits intoelastic:mainfrom
sphilipse:move-connectors-to-backend

Conversation

@sphilipse
Copy link
Copy Markdown
Member

@sphilipse sphilipse commented Apr 16, 2026

Summary

This moves the model resolution entirely to the backend, no longer splitting the logic between two places.

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

sphilipse and others added 2 commits April 16, 2026 18:30
Move default-connector UI settings lookup, feature-endpoint merging, and
recommended-endpoint flagging from the client `useLoadConnectors`/`loadConnectors`
wrappers into the search_inference_endpoints `/internal/search_inference_endpoints/connectors`
route. The frontend now fetches a pre-merged list and maps it to AIConnector.

- Backend reads `genAiSettings:defaultAIConnector` and
  `genAiSettings:defaultAIConnector.defaultOnly` from `context.core.uiSettings.client`
  and applies the same default-only and default-prepend logic the client used to run.
- New `server/lib/merge_connectors.ts` helper applies the ordering previously in
  `mergeConnectorsFromApiResponse` and stamps `isRecommended: true` on recommended
  endpoints when no saved-object override is set.
- API response body slimmed to `{ connectors, soEntryFound }`; `allConnectors` is
  no longer returned since the client no longer merges.
- `useLoadConnectors` and `loadConnectors` now fetch and map only; `settings` is
  kept as an optional `@deprecated` prop so existing call sites compile. Removal
  of `settings` from callers will follow in a separate PR.
- Scout and Cypress fixtures updated to match the new response shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sphilipse sphilipse requested a review from a team as a code owner April 16, 2026 16:33
@sphilipse sphilipse added the release_note:skip Skip the PR/issue when compiling release notes label Apr 16, 2026
@sphilipse sphilipse requested review from a team as code owners April 16, 2026 16:33
@sphilipse sphilipse requested review from a team as code owners April 16, 2026 16:33
@sphilipse sphilipse added backport:version Backport to applied version labels v9.4.0 v9.5.0 labels Apr 16, 2026
@sphilipse sphilipse requested review from pzl and szwarckonrad April 16, 2026 16:33
Copy link
Copy Markdown
Contributor

@szwarckonrad szwarckonrad left a comment

Choose a reason for hiding this comment

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

EDR Workflows change LGTM

@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented Apr 16, 2026

Catch flakiness early (recommended)

Recommended before merge: run the flaky test runner against this PR to catch flakiness early.

Trigger a run with the Flaky Test Runner UI or post this comment on the PR:

/flaky scoutConfig:x-pack/platform/plugins/shared/streams_app/test/scout/ui/playwright.config.ts:30 scoutConfig:x-pack/platform/plugins/shared/automatic_import/test/scout_automatic_import/ui/playwright.config.ts:30

This check is experimental. Share your feedback in the #appex-qa channel.

Posted via Macroscope — Flaky Test Runner nudge

@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented Apr 16, 2026

Approvability

Verdict: Needs human review

This PR relocates connector resolution logic from client to server, fundamentally changing where default-connector and feature-endpoint merging decisions are made. The author does not own any of the affected files, which span multiple teams (@elastic/search-kibana, @elastic/security-defend-workflows, etc.), requiring review from designated code owners.

You can customize Macroscope's approvability policy. Learn more.

Copy link
Copy Markdown
Contributor

@bhapas bhapas left a comment

Choose a reason for hiding this comment

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

Automatic Import changes LGTM

Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com>
@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Apr 16, 2026

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] affected Scout: [ platform / streams_app-stateful-classic ] plugin / local-stateful-classic - Stream data routing - AI suggestions generation - should handle empty suggestions response
  • [job] [logs] affected Scout: [ platform / streams_app-stateful-classic ] plugin / local-stateful-classic - Stream data routing - AI suggestions generation - should successfully generate and display suggestions

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
agentBuilder 1383 1382 -1
automaticImport 256 255 -1
elasticAssistant 612 611 -1
observabilityAgentBuilder 104 103 -1
observabilityAIAssistant 178 177 -1
securitySolution 9252 9251 -1
streamsApp 1843 1842 -1
workplaceAIApp 437 435 -2
total -9

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
agentBuilder 1.1MB 1.1MB -775.0B
automaticImport 322.5KB 321.7KB -796.0B
observabilityAgentBuilder 24.6KB 23.8KB -814.0B
observabilityAIAssistant 20.3KB 20.4KB +1.0B
securitySolution 11.7MB 11.7MB -1.5KB
streamsApp 2.0MB 2.0MB -852.0B
workplaceAIApp 514.6KB 513.8KB -822.0B
total -5.5KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
agentBuilder 43.3KB 43.2KB -50.0B
elasticAssistant 272.7KB 272.0KB -796.0B
observabilityAgentBuilder 9.5KB 9.5KB +6.0B
observabilityAIAssistant 66.4KB 65.6KB -740.0B
total -1.5KB
Unknown metric groups

API count

id before after diff
@kbn/inference-common 396 397 +1

References to deprecated APIs

id before after diff
@kbn/elastic-assistant 7 16 +9
agentBuilder 51 52 +1
automaticImport 1 2 +1
observabilityAgentBuilder 0 1 +1
observabilityAIAssistant 2 3 +1
securitySolution 536 544 +8
streamsApp 9 11 +2
workplaceAIApp 9 10 +1
total +24

Unreferenced deprecated APIs

id before after diff
@kbn/elastic-assistant 7 16 +9
agentBuilder 51 52 +1
automaticImport 1 2 +1
observabilityAgentBuilder 0 1 +1
observabilityAIAssistant 2 3 +1
securitySolution 536 544 +8
streamsApp 9 11 +2
workplaceAIApp 9 10 +1
total +24

History

@sphilipse sphilipse enabled auto-merge (squash) April 17, 2026 07:43
@sphilipse sphilipse merged commit 32bdcc3 into elastic:main Apr 17, 2026
23 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 9.4

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

@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
9.4 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 263843

Questions ?

Please refer to the Backport tool documentation

@achyutjhunjhunwala achyutjhunjhunwala added Feature:SigEvents Significant events feature, related to streams and rules/alerts (RnA) Team:SigEvents Project team working on Significant Events and removed Feature:SigEvents Significant events feature, related to streams and rules/alerts (RnA) Team:SigEvents Project team working on Significant Events labels Apr 17, 2026
@sphilipse
Copy link
Copy Markdown
Member Author

💚 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

sphilipse added a commit to sphilipse/kibana that referenced this pull request Apr 17, 2026
## Summary

This moves the model resolution entirely to the backend, no longer
splitting the logic between two places.

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com>
(cherry picked from commit 32bdcc3)

# Conflicts:
#	x-pack/platform/plugins/shared/streams_app/test/scout/ui/tests/data_management/data_routing/ai_suggestions_button.spec.ts
#	x-pack/solutions/security/plugins/security_solution/public/management/cypress/tasks/insights.ts
sphilipse added a commit that referenced this pull request Apr 17, 2026
…#264107)

# Backport

This will backport the following commits from `main` to `9.4`:
- [[Inference] Move model resolution entirely to backend
(#263843)](#263843)

<!--- Backport version: 11.0.1 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Sander
Philipse","email":"94373878+sphilipse@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-04-17T08:19:40Z","message":"[Inference]
Move model resolution entirely to backend (#263843)\n\n##
Summary\n\nThis moves the model resolution entirely to the backend, no
longer\nsplitting the logic between two places.\n\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers
should verify this PR satisfies this list as well.\n\n- [x] Any text
added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n-
[x]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: Claude Opus 4.7 (1M context)
<noreply@anthropic.com>\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
macroscopeapp[bot]
<170038800+macroscopeapp[bot]@users.noreply.github.com>","sha":"32bdcc3ed32a657c2cc9bc4dc180c7be27d6a1e4","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Search","backport:version","v9.4.0","v9.5.0"],"title":"[Inference]
Move model resolution entirely to
backend","number":263843,"url":"https://github.com/elastic/kibana/pull/263843","mergeCommit":{"message":"[Inference]
Move model resolution entirely to backend (#263843)\n\n##
Summary\n\nThis moves the model resolution entirely to the backend, no
longer\nsplitting the logic between two places.\n\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers
should verify this PR satisfies this list as well.\n\n- [x] Any text
added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n-
[x]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: Claude Opus 4.7 (1M context)
<noreply@anthropic.com>\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
macroscopeapp[bot]
<170038800+macroscopeapp[bot]@users.noreply.github.com>","sha":"32bdcc3ed32a657c2cc9bc4dc180c7be27d6a1e4"}},"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/263843","number":263843,"mergeCommit":{"message":"[Inference]
Move model resolution entirely to backend (#263843)\n\n##
Summary\n\nThis moves the model resolution entirely to the backend, no
longer\nsplitting the logic between two places.\n\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers
should verify this PR satisfies this list as well.\n\n- [x] Any text
added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n-
[x]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: Claude Opus 4.7 (1M context)
<noreply@anthropic.com>\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by:
macroscopeapp[bot]
<170038800+macroscopeapp[bot]@users.noreply.github.com>","sha":"32bdcc3ed32a657c2cc9bc4dc180c7be27d6a1e4"}}]}]
BACKPORT-->
rStelmach added a commit that referenced this pull request Apr 21, 2026
closes: #258589

## Summary

Re-enables the Streams UI test `should not show Technical Preview badge
when AI suggestions are unavailable` on serverless observability (MKI).
The test was skipped in #263984 while it was failing deterministically
on the MKI.
 The underlying bug was fixed by #263843 after this test was skipped


## Root cause

**Root cause of the original failure (fixed):**
Before #263843, `useLoadConnectors` in `@kbn/inference-connectors` had a
client-side fallback that called `fetchConnectorById` against `GET
/internal/inference/connectors/{id}` whenever `soEntryFound === false`
and `defaultConnectorId` was truthy. The test's `page.route` mock only
covered `**/internal/search_inference_endpoints/connectors*`, so the
fallback slipped past the mock and returned the project's EIS connector.
The Technical Preview badge (and the "Elastic Managed LLM is the new
default" callout) then rendered, and the assertion failed.

This was MKI-only because the fallback is gated on `defaultConnectorId`
being truthy, which requires the `GEN_AI_SETTINGS_DEFAULT_AI_CONNECTOR`
uiSetting to be configured. Serverless observability CI projects
preconfigure that setting to an EIS inference endpoint; local stateful /
ECH environments do not, so the fallback short-circuited there.

**How #263843 fixed it:**
Removed the client-side fallback entirely. Default-connector merging now
happens server-side in `mergeConnectors`
(`x-pack/platform/plugins/shared/search_inference_endpoints/server/lib/merge_connectors.ts`).
After the fix, `useLoadConnectors` makes exactly one HTTP call to the
endpoint the test already mocks.
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 release_note:skip Skip the PR/issue when compiling release notes Team:Search v9.4.0 v9.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants