Skip to content

[Security assistant] Remove title creation step from graph#226864

Merged
stephmilovic merged 7 commits intoelastic:mainfrom
stephmilovic:fast_title
Jul 8, 2025
Merged

[Security assistant] Remove title creation step from graph#226864
stephmilovic merged 7 commits intoelastic:mainfrom
stephmilovic:fast_title

Conversation

@stephmilovic
Copy link
Copy Markdown
Contributor

@stephmilovic stephmilovic commented Jul 7, 2025

Summary

Having the generateChatTitle as part of the graph caused the time to first token to be delayed by 1s. Removing the step from the graph and calling it async without await resolves the issue.

Running the assistant with the input hi on a new chat 10 times off of main resulted in an average runtime for 3.00s. Running the assistant with the input hi on a new chat 10 times off of this branch resulted in an average runtime for 2.05s.

Why not parallel in graph?

Previously, the generateChatTitle step was part of the conversation graph execution chain, branching from getPersistedConversation. While it was intended to run in parallel to the main agent response path, it internally triggered a model call via the graph’s own execution infrastructure. Because LangGraph serializes graph steps and model invocations within a single graph execution, this caused the graph to block at this point — waiting for the title generation to complete before continuing to the agent step.

Moving this step to a RunnableParallel was not a viable option, as the model call within generateChatTitle would still execute through the same LangGraph graph runner and event loop, meaning the parent graph execution would remain blocked until all child runnables completed. Since LangGraph JS does not currently support true parallel graph branches that run independently within the same orchestrated execution, this approach would not resolve the blocking behavior.

@stephmilovic stephmilovic added release_note:skip Skip the PR/issue when compiling release notes Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Security Generative AI Security Generative AI backport:version Backport to applied version labels v9.1.0 v8.19.0 v9.2.0 v8.18.4 v9.0.4 labels Jul 7, 2025
@stephmilovic stephmilovic changed the title [Security assistant] Parallel title creation step [Security assistant] Remove title creation step from graph Jul 7, 2025
@stephmilovic stephmilovic marked this pull request as ready for review July 7, 2025 21:04
@stephmilovic stephmilovic requested a review from a team as a code owner July 7, 2025 21:04
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

Copy link
Copy Markdown
Member

@KDKHD KDKHD left a comment

Choose a reason for hiding this comment

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

Tested this change locally and it is working well! There is a noticeable latency improvement!

@stephmilovic stephmilovic merged commit 2278db5 into elastic:main Jul 8, 2025
12 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.18, 8.19, 9.0, 9.1

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

@kibanamachine
Copy link
Copy Markdown
Contributor

@stephmilovic
Copy link
Copy Markdown
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

stephmilovic added a commit to stephmilovic/kibana that referenced this pull request Jul 8, 2025
…26864)

(cherry picked from commit 2278db5)

# Conflicts:
#	x-pack/solutions/security/plugins/elastic_assistant/docs/img/default_assistant_graph.png
#	x-pack/solutions/security/plugins/elastic_assistant/docs/img/default_attack_discovery_graph.png
stephmilovic added a commit to stephmilovic/kibana that referenced this pull request Jul 8, 2025
…26864)

(cherry picked from commit 2278db5)

# Conflicts:
#	x-pack/solutions/security/plugins/elastic_assistant/docs/img/default_assistant_graph.png
#	x-pack/solutions/security/plugins/elastic_assistant/docs/img/default_attack_discovery_graph.png
#	x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/graph.ts
stephmilovic added a commit to stephmilovic/kibana that referenced this pull request Jul 8, 2025
…26864)

(cherry picked from commit 2278db5)

# Conflicts:
#	x-pack/solutions/security/plugins/elastic_assistant/docs/img/default_assistant_graph.png
#	x-pack/solutions/security/plugins/elastic_assistant/docs/img/default_attack_discovery_graph.png
#	x-pack/solutions/security/plugins/elastic_assistant/server/lib/langchain/graphs/default_assistant_graph/graph.ts
@stephmilovic
Copy link
Copy Markdown
Contributor Author

💚 All backports created successfully

Status Branch Result
9.0
8.18

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

Questions ?

Please refer to the Backport tool documentation

stephmilovic added a commit to stephmilovic/kibana that referenced this pull request Jul 8, 2025
…26864)

(cherry picked from commit 2278db5)

# Conflicts:
#	x-pack/solutions/security/plugins/elastic_assistant/docs/img/default_assistant_graph.png
#	x-pack/solutions/security/plugins/elastic_assistant/docs/img/default_attack_discovery_graph.png
@stephmilovic
Copy link
Copy Markdown
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

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 reverted Team:Security Generative AI Security Generative AI Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.18.4 v8.19.0 v9.0.4 v9.1.0 v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants