Skip to content

[Agent builder] Builtin Product documentation tool#242598

Merged
stephmilovic merged 32 commits intoelastic:mainfrom
stephmilovic:product_docs_ab_tool
Dec 2, 2025
Merged

[Agent builder] Builtin Product documentation tool#242598
stephmilovic merged 32 commits intoelastic:mainfrom
stephmilovic:product_docs_ab_tool

Conversation

@stephmilovic
Copy link
Copy Markdown
Contributor

@stephmilovic stephmilovic commented Nov 11, 2025

Summary

Adds a product documentation tool to Agent Builder that retrieves Elastic product documentation using the LlmTasks plugin. The tool uses the conditional availability pattern and is only available when product documentation is installed.

Changes

  • Added platform.core.product_documentation builtin tool to agent_builder_platform that searches Elastic product docs
  • Tool is registered in plugin setup() with conditional availability using the availability configuration pattern
  • Availability is checked at runtime via llmTasks.retrieveDocumentationAvailable() using the inference endpoint from the connector configuration
  • Tool dynamically extracts inferenceId from the connector config when using an inference connector, falling back to the default ELSER endpoint (defaultInferenceEndpoints.ELSER) for other connector types
  • Tool accesses llmTasks via closure through coreSetup.getStartServices() instead of through service dependencies

Technical Details

  • Added llmTasks as optional dependency to agent_builder_platform plugin (kibana.jsonc and PluginStartDependencies)
  • Tool registration moved to registerTools() in plugin setup() phase, following the same pattern as other built-in tools
  • Uses availability configuration with cacheMode: 'space' to conditionally show/hide the tool based on product documentation availability
  • llmTasks is accessed via closure in the tool definition, not passed through ToolHandlerContext or internal service layers
  • Availability handler uses coreSetup.getStartServices() to access llmTasks at runtime
  • Defaults to defaultInferenceEndpoints.ELSER, TODO to update to dynamic inferenceId

Considerations

  • Tool requires product documentation to be installed via the product-doc-base plugin
  • Tool availability is checked per-space and cached for performance
  • No Kibana restart required - tool appears/disappears dynamically based on availability

@stephmilovic stephmilovic added release_note:enhancement backport:skip This PR does not require backporting Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v9.3.0 labels Nov 11, 2025
@stephmilovic stephmilovic marked this pull request as ready for review November 12, 2025 21:14
@stephmilovic stephmilovic requested a review from a team as a code owner November 12, 2025 21:14
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

Copy link
Copy Markdown
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

The tool implementation looks good. I have concerns on how the tool is being registered and how we propagate the required llmTasks dependency to it (more details on slack)

Comment thread x-pack/platform/plugins/shared/onechat/server/services/tools/tools_service.ts Outdated
@stephmilovic
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

Comment on lines +64 to +68
// Try to get inferenceId from the connector, fall back to default ELSER endpoint
let inferenceId = defaultInferenceEndpoints.ELSER;
if (connector.type === InferenceConnectorType.Inference && connector.config?.inferenceId) {
inferenceId = connector.config.inferenceId;
}
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.

@pgayvallet not sure this is the best way to make the inference endpoint configurable, but not sure another way at the moment. Do you think we should go forward with getting it off the connector, should I just default it to ELSER or do you see another way forward?

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 have a better idea. Now that we're getting "unified" through AB, I imagine we should have a platform level setting for the embedding model we use for our semantic_text fields at some point. Until we do...

One question - is that inferenceId on the inference connector config something users can already configure to specify an embedding model to use for a specific connector? if so, I'm fine using it. Otherwise I would just KISS and default to using ELSER until we figure out how to do it better.

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.

I think inferenceId is only on inference connector type:

  elastic-llm:
    name: Elastic LLM
    actionTypeId: .inference
    exposeConfig: true
    config:
      provider: 'elastic'
      taskType: 'chat_completion'
      inferenceId: '.rainbow-sprinkles-elastic'
      providerConfig:
        model_id: 'rainbow-sprinkles'

And considering we're expecting .elser-2-elasticsearch or .multilingual-e5-small-elasticsearch, that doesn't seem right. I'll hardcode to ELSER for now and leave a comment

Copy link
Copy Markdown
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +64 to +68
// Try to get inferenceId from the connector, fall back to default ELSER endpoint
let inferenceId = defaultInferenceEndpoints.ELSER;
if (connector.type === InferenceConnectorType.Inference && connector.config?.inferenceId) {
inferenceId = connector.config.inferenceId;
}
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 have a better idea. Now that we're getting "unified" through AB, I imagine we should have a platform level setting for the embedding model we use for our semantic_text fields at some point. Until we do...

One question - is that inferenceId on the inference connector config something users can already configure to specify an embedding model to use for a specific connector? if so, I'm fine using it. Otherwise I would just KISS and default to using ELSER until we figure out how to do it better.

@stephmilovic
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Copy Markdown
Contributor

merge conflict between base and head

@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Scout Test Run Builder / checkbox
  • [job] [logs] Scout Test Run Builder / serverless-security - EUI testing wrapper: EuiCheckBox - checkbox
  • [job] [logs] Scout Test Run Builder / serverless-security - EUI testing wrapper: EuiComboBox - with multiple selections (pills)
  • [job] [logs] Scout Test Run Builder / with multiple selections (pills)

Metrics [docs]

Async chunks

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

id before after diff
onechat 465.4KB 465.5KB +49.0B

History

@stephmilovic stephmilovic merged commit 36d7faa into elastic:main Dec 2, 2025
12 checks passed
NicholasPeretti pushed a commit to NicholasPeretti/kibana that referenced this pull request Dec 2, 2025
JordanSh pushed a commit to JordanSh/kibana that referenced this pull request Dec 9, 2025
spong added a commit that referenced this pull request Dec 11, 2025
…ocumentation (#245749)

## Summary

This PR adds a new `Documentation` section to the `GenAI Settings` page
for managing the installation of documentation assets like the [Elastic
Documentation](https://www.elastic.co/docs/reference/kibana/configuration-reference/ai-assistant-settings)
used by the [Product Docs Platform
Tool](#242598) and the Security
Labs content used by the `security.security_labs_search` tool

Design issue: elastic/ai-enhancements#77

<p align="center">
<img width="700"
src="https://github.com/user-attachments/assets/46d7805e-5ef1-4213-8ec9-25875a4f039d"
/>
</p> 


> [!NOTE]
> Security Labs content is not yet served up by the product docs CDN, so
it is currently a disabled placeholder until I work
#244946 next. We can hide this
item for now if that is preferred.


### Implementation notes

* The `product_docs` API's are called directly from the client instead
of plumbing a new AB API. In support of this, the `llm_product_doc`
privilege was added to the `ONECHAT_FEATURE_ID`. If this is not desired,
we can remove this addition and plumb a dedicated API.
* This UI section should be conditionally visible based on if the Agent
Builder experience is enabled/feature is available. ~I need to confirm,
but I believe this is coming in
#244532 This functionality has
been added.
* Client hooks for managing product docs were added to
`/ai_infra/product_doc_base` instead of `gen_ai_settings`. I originally
had them in the setting public code, but figured they made more sense
alongside the product docs. Happy to change is there is preference here.
* As previously discussed, we're only supporting installing ELSER
embeddings at the moment. ~We'll probably want to update the Platform
Docs tool do instruct the model to do query re-writing to english in
support of this.~ This is done in:
#245259
* This uses the same product docs API as the O11y/Security Assistants,
so there is no compatibility issues when switching the AB experience
on/off or using the old assistants.
* RBAC support provided such that documentation management actions are
disabled unless the user has `agentBuilder['all']` Kibana feature
privileges.


### 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)
- [ ]
[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
- [X] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

_PR developed with Cursor + Opus 4.5_

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
seanrathier pushed a commit to seanrathier/kibana that referenced this pull request Dec 15, 2025
…ocumentation (elastic#245749)

## Summary

This PR adds a new `Documentation` section to the `GenAI Settings` page
for managing the installation of documentation assets like the [Elastic
Documentation](https://www.elastic.co/docs/reference/kibana/configuration-reference/ai-assistant-settings)
used by the [Product Docs Platform
Tool](elastic#242598) and the Security
Labs content used by the `security.security_labs_search` tool

Design issue: elastic/ai-enhancements#77

<p align="center">
<img width="700"
src="https://github.com/user-attachments/assets/46d7805e-5ef1-4213-8ec9-25875a4f039d"
/>
</p> 


> [!NOTE]
> Security Labs content is not yet served up by the product docs CDN, so
it is currently a disabled placeholder until I work
elastic#244946 next. We can hide this
item for now if that is preferred.


### Implementation notes

* The `product_docs` API's are called directly from the client instead
of plumbing a new AB API. In support of this, the `llm_product_doc`
privilege was added to the `ONECHAT_FEATURE_ID`. If this is not desired,
we can remove this addition and plumb a dedicated API.
* This UI section should be conditionally visible based on if the Agent
Builder experience is enabled/feature is available. ~I need to confirm,
but I believe this is coming in
elastic#244532 This functionality has
been added.
* Client hooks for managing product docs were added to
`/ai_infra/product_doc_base` instead of `gen_ai_settings`. I originally
had them in the setting public code, but figured they made more sense
alongside the product docs. Happy to change is there is preference here.
* As previously discussed, we're only supporting installing ELSER
embeddings at the moment. ~We'll probably want to update the Platform
Docs tool do instruct the model to do query re-writing to english in
support of this.~ This is done in:
elastic#245259
* This uses the same product docs API as the O11y/Security Assistants,
so there is no compatibility issues when switching the AB experience
on/off or using the old assistants.
* RBAC support provided such that documentation management actions are
disabled unless the user has `agentBuilder['all']` Kibana feature
privileges.


### 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)
- [ ]
[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
- [X] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

_PR developed with Cursor + Opus 4.5_

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:enhancement Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants