Skip to content

Comments

[Obs AI Assistant] Migrate anonymization to inference#225539

Merged
dgieselaar merged 54 commits intoelastic:mainfrom
neptunian:migrate-anonymization-to-inference
Jul 7, 2025
Merged

[Obs AI Assistant] Migrate anonymization to inference#225539
dgieselaar merged 54 commits intoelastic:mainfrom
neptunian:migrate-anonymization-to-inference

Conversation

@neptunian
Copy link
Contributor

@neptunian neptunian commented Jun 26, 2025

  • Migrates anonymization functionality from observability ai assistant to inference plugin
  • Migrates the anonymization rules advanced / ui setting to inference plugin
  • Changes advanced setting to aiAssistant:anonymizationRules and adds allowedEntityClasses for users to specify which entity types to anonymize from the NER model

code contribution models: claud 3.7 sonnet, o3

@neptunian neptunian added release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels labels Jun 27, 2025

return result;
}),
defaultIfEmpty(messages)
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this?

Copy link
Contributor Author

@neptunian neptunian Jun 27, 2025

Choose a reason for hiding this comment

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

the filter is strict, checking for deanonymized_input or deanonymized_output and if nothing passes it, nothing will emit without this. I could broaden the filter and add some conditions and return the message in there if that's a preferred style / safer. I thought this was a bit more readable.

Comment on lines +65 to +71
toolCalls?: Array<{
toolCallId: string;
function: {
name: string;
arguments: Record<string, any>;
};
}>;
Copy link
Contributor

Choose a reason for hiding this comment

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

I get confused about the data modeling here. I think this should either just be the output from the inference client, or it should be our own model (which means single function_call).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't that the output from the inference client? array of toolCalls.

Copy link
Contributor

Choose a reason for hiding this comment

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

what I mean is you have mixed up the types from the inference client (indeed, multiple tool calls), and our format: name is ours, toolCallId is from the inference client, but they serve the same purpose (identifying the tool call request). We can leave it for later but we should fix it.

@neptunian neptunian marked this pull request as ready for review June 27, 2025 17:50
@neptunian neptunian requested review from a team as code owners June 27, 2025 17:50
@botelastic botelastic bot added ci:project-deploy-observability Create an Observability project Team:Obs AI Assistant Observability AI Assistant labels Jun 27, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant)

@github-actions
Copy link
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!)

@dgieselaar dgieselaar force-pushed the migrate-anonymization-to-inference branch from 4db3492 to d620263 Compare July 4, 2025 12:41
@dgieselaar
Copy link
Contributor

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

elasticmachine commented Jul 7, 2025

💚 Build Succeeded

  • Buildkite Build
  • Commit: fa1161d
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-225539-fa1161d44fe7

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
automaticImport 796 797 +1
elasticAssistant 451 452 +1
inference 48 49 +1
observabilityAIAssistant 108 107 -1
observabilityAIAssistantApp 434 435 +1
observabilityAiAssistantManagement 265 266 +1
productDocBase 40 41 +1
searchAssistant 151 152 +1
searchPlayground 366 367 +1
securitySolution 7819 7820 +1
workchatApp 181 182 +1
total +9

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/inference-common 130 161 +31
observabilityAIAssistant 438 429 -9
total +22

Async chunks

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

id before after diff
observabilityAIAssistantApp 176.1KB 176.1KB -56.0B
searchAssistant 102.9KB 102.8KB -56.0B
total -112.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
observabilityAIAssistant 32 30 -2

Page load bundle

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

id before after diff
observabilityAIAssistant 41.9KB 41.4KB -553.0B
Unknown metric groups

API count

id before after diff
@kbn/inference-common 271 302 +31
observabilityAIAssistant 444 431 -13
total +18

History

@dgieselaar dgieselaar merged commit b1bdc6e into elastic:main Jul 7, 2025
12 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19, 9.1

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

kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Jul 7, 2025
- Migrates anonymization functionality from observability ai assistant
to inference plugin
- Migrates the anonymization rules advanced / ui setting to inference
plugin
- Changes advanced setting to `aiAssistant:anonymizationRules` and adds
`allowedEntityClasses` for users to specify which entity types to
anonymize from the NER model

code contribution models: claud 3.7 sonnet, o3

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit b1bdc6e)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
8.19 Backport failed because of merge conflicts

You might need to backport the following PRs to 8.19:
- [Obs AI Assistant] Collapse *query tool calls (#226078)
- Move test utils from legacy api to agnostic (#224381)
9.1

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

Manual backport

To create the backport manually run:

node scripts/backport --pr 225539

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jul 7, 2025
…#226763)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[Obs AI Assistant] Migrate anonymization to inference
(#225539)](#225539)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Sandra
G","email":"neptunian@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-07-07T10:36:37Z","message":"[Obs
AI Assistant] Migrate anonymization to inference (#225539)\n\n- Migrates
anonymization functionality from observability ai assistant\nto
inference plugin\n- Migrates the anonymization rules advanced / ui
setting to inference\nplugin\n- Changes advanced setting to
`aiAssistant:anonymizationRules` and adds\n`allowedEntityClasses` for
users to specify which entity types to\nanonymize from the NER
model\n\n\ncode contribution models: claud 3.7 sonnet,
o3\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Dario
Gieselaar <dario.gieselaar@elastic.co>\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"b1bdc6ec58e8f16ea9f6b84e80304a05a475f354","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Obs
AI
Assistant","ci:project-deploy-observability","backport:version","v9.1.0","v8.19.0","v9.2.0"],"title":"[Obs
AI Assistant] Migrate anonymization to
inference","number":225539,"url":"https://github.com/elastic/kibana/pull/225539","mergeCommit":{"message":"[Obs
AI Assistant] Migrate anonymization to inference (#225539)\n\n- Migrates
anonymization functionality from observability ai assistant\nto
inference plugin\n- Migrates the anonymization rules advanced / ui
setting to inference\nplugin\n- Changes advanced setting to
`aiAssistant:anonymizationRules` and adds\n`allowedEntityClasses` for
users to specify which entity types to\nanonymize from the NER
model\n\n\ncode contribution models: claud 3.7 sonnet,
o3\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Dario
Gieselaar <dario.gieselaar@elastic.co>\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"b1bdc6ec58e8f16ea9f6b84e80304a05a475f354"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/225539","number":225539,"mergeCommit":{"message":"[Obs
AI Assistant] Migrate anonymization to inference (#225539)\n\n- Migrates
anonymization functionality from observability ai assistant\nto
inference plugin\n- Migrates the anonymization rules advanced / ui
setting to inference\nplugin\n- Changes advanced setting to
`aiAssistant:anonymizationRules` and adds\n`allowedEntityClasses` for
users to specify which entity types to\nanonymize from the NER
model\n\n\ncode contribution models: claud 3.7 sonnet,
o3\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Dario
Gieselaar <dario.gieselaar@elastic.co>\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"b1bdc6ec58e8f16ea9f6b84e80304a05a475f354"}}]}]
BACKPORT-->

Co-authored-by: Sandra G <neptunian@users.noreply.github.com>
Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
neptunian added a commit to neptunian/kibana that referenced this pull request Jul 10, 2025
- Migrates anonymization functionality from observability ai assistant
to inference plugin
- Migrates the anonymization rules advanced / ui setting to inference
plugin
- Changes advanced setting to `aiAssistant:anonymizationRules` and adds
`allowedEntityClasses` for users to specify which entity types to
anonymize from the NER model

code contribution models: claud 3.7 sonnet, o3

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit b1bdc6e)

# Conflicts:
#	x-pack/platform/plugins/shared/observability_ai_assistant/server/service/client/index.ts
@neptunian
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.19

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

Questions ?

Please refer to the Backport tool documentation

neptunian added a commit that referenced this pull request Jul 11, 2025
#227543)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Obs AI Assistant] Migrate anonymization to inference
(#225539)](#225539)

<!--- Backport version: 10.0.1 -->

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

<!--BACKPORT [{"author":{"name":"Sandra
G","email":"neptunian@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-07-07T10:36:37Z","message":"[Obs
AI Assistant] Migrate anonymization to inference (#225539)\n\n- Migrates
anonymization functionality from observability ai assistant\nto
inference plugin\n- Migrates the anonymization rules advanced / ui
setting to inference\nplugin\n- Changes advanced setting to
`aiAssistant:anonymizationRules` and adds\n`allowedEntityClasses` for
users to specify which entity types to\nanonymize from the NER
model\n\n\ncode contribution models: claud 3.7 sonnet,
o3\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Dario
Gieselaar <dario.gieselaar@elastic.co>\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"b1bdc6ec58e8f16ea9f6b84e80304a05a475f354","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Obs
AI
Assistant","ci:project-deploy-observability","backport:version","v9.1.0","v8.19.0","v9.2.0"],"title":"[Obs
AI Assistant] Migrate anonymization to
inference","number":225539,"url":"https://github.com/elastic/kibana/pull/225539","mergeCommit":{"message":"[Obs
AI Assistant] Migrate anonymization to inference (#225539)\n\n- Migrates
anonymization functionality from observability ai assistant\nto
inference plugin\n- Migrates the anonymization rules advanced / ui
setting to inference\nplugin\n- Changes advanced setting to
`aiAssistant:anonymizationRules` and adds\n`allowedEntityClasses` for
users to specify which entity types to\nanonymize from the NER
model\n\n\ncode contribution models: claud 3.7 sonnet,
o3\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Dario
Gieselaar <dario.gieselaar@elastic.co>\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"b1bdc6ec58e8f16ea9f6b84e80304a05a475f354"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/226763","number":226763,"state":"MERGED","mergeCommit":{"sha":"44f745deae84da15c906bb64d2a9607b493b40b7","message":"[9.1]
[Obs AI Assistant] Migrate anonymization to inference (#225539)
(#226763)\n\n# Backport\n\nThis will backport the following commits from
`main` to `9.1`:\n- [[Obs AI Assistant] Migrate anonymization to
inference\n(#225539)](https://github.com/elastic/kibana/pull/225539)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by:
Sandra G <neptunian@users.noreply.github.com>\nCo-authored-by: Dario
Gieselaar <dario.gieselaar@elastic.co>\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/225539","number":225539,"mergeCommit":{"message":"[Obs
AI Assistant] Migrate anonymization to inference (#225539)\n\n- Migrates
anonymization functionality from observability ai assistant\nto
inference plugin\n- Migrates the anonymization rules advanced / ui
setting to inference\nplugin\n- Changes advanced setting to
`aiAssistant:anonymizationRules` and adds\n`allowedEntityClasses` for
users to specify which entity types to\nanonymize from the NER
model\n\n\ncode contribution models: claud 3.7 sonnet,
o3\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Dario
Gieselaar <dario.gieselaar@elastic.co>\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"b1bdc6ec58e8f16ea9f6b84e80304a05a475f354"}}]}]
BACKPORT-->
neptunian added a commit that referenced this pull request Jul 11, 2025
## Summary

Followup to #225539

Adds an anonymization-regex worker pool to run user-defined regex
patterns out-of-process, protecting the Node event-loop from
catastrophic back-tracking.

For internal use we have config to adjust or turn off the worker:
• `enabled` – turn worker on/off
• `minThreads` / `maxThreads` – worker size
• `idleTimeout` – how long a worker thread is allowed to be idle
• `taskTimeout` – per-regex task limit

Contributions by windsurf(o3).
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 11, 2025
## Summary

Followup to elastic#225539

Adds an anonymization-regex worker pool to run user-defined regex
patterns out-of-process, protecting the Node event-loop from
catastrophic back-tracking.

For internal use we have config to adjust or turn off the worker:
• `enabled` – turn worker on/off
• `minThreads` / `maxThreads` – worker size
• `idleTimeout` – how long a worker thread is allowed to be idle
• `taskTimeout` – per-regex task limit

Contributions by windsurf(o3).

(cherry picked from commit 1b9063a)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 11, 2025
## Summary

Followup to elastic#225539

Adds an anonymization-regex worker pool to run user-defined regex
patterns out-of-process, protecting the Node event-loop from
catastrophic back-tracking.

For internal use we have config to adjust or turn off the worker:
• `enabled` – turn worker on/off
• `minThreads` / `maxThreads` – worker size
• `idleTimeout` – how long a worker thread is allowed to be idle
• `taskTimeout` – per-regex task limit

Contributions by windsurf(o3).

(cherry picked from commit 1b9063a)
kertal pushed a commit to kertal/kibana that referenced this pull request Jul 25, 2025
- Migrates anonymization functionality from observability ai assistant
to inference plugin
- Migrates the anonymization rules advanced / ui setting to inference
plugin
- Changes advanced setting to `aiAssistant:anonymizationRules` and adds
`allowedEntityClasses` for users to specify which entity types to
anonymize from the NER model


code contribution models: claud 3.7 sonnet, o3

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
kertal pushed a commit to kertal/kibana that referenced this pull request Jul 25, 2025
## Summary

Followup to elastic#225539

Adds an anonymization-regex worker pool to run user-defined regex
patterns out-of-process, protecting the Node event-loop from
catastrophic back-tracking.

For internal use we have config to adjust or turn off the worker:
• `enabled` – turn worker on/off
• `minThreads` / `maxThreads` – worker size
• `idleTimeout` – how long a worker thread is allowed to be idle
• `taskTimeout` – per-regex task limit

Contributions by windsurf(o3).
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 Assistant Observability AI Assistant v8.19.0 v9.1.0 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants