[Inference] Move model resolution entirely to backend#263843
[Inference] Move model resolution entirely to backend#263843sphilipse merged 7 commits intoelastic:mainfrom
Conversation
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>
szwarckonrad
left a comment
There was a problem hiding this comment.
EDR Workflows change LGTM
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: This check is experimental. Share your feedback in the #appex-qa channel. Posted via Macroscope — Flaky Test Runner nudge |
ApprovabilityVerdict: 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. |
bhapas
left a comment
There was a problem hiding this comment.
Automatic Import changes LGTM
Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com>
💔 Build Failed
Failed CI Steps
Test Failures
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsAPI count
References to deprecated APIs
Unreferenced deprecated APIs
History |
|
Starting backport for target branches: 9.4 https://github.com/elastic/kibana/actions/runs/24555307076 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
## 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
…#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-->
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.
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.