-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Security Assistant] Migrates to LangGraph and adds KB Tools #184554
Conversation
… to use kbDataClient instead of esStore
|
||
const userFilter = [ | ||
{ | ||
nested: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should extend the filter to support empty("shared") KBs, which are available for all users in the space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working through adding the different permutations of kb mock data today for #184974 and will use that to start crafting tests to cover these scenarios.
I want to take a moment and rethink how we're categorizing/namespacing content using kbResource
though to see if there will be any issues here. For now I've kept things matching the original KB implementation, and just introduced the user
kbResource for all user created entries. We will also need to capture entryType
somewhere to differentiate between raw text content and index-backed entries. Would be nice to have a catch-all tags
for organization and labeling too.
I will start thinking through more of this early next week as I get back to plumbing through the remainder of the kbDataClient methods and REST API's, but if you have any thoughts here I would love to hear them 🙂
# Conflicts: # package.json
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Garrett! 🙇
💛 Build succeeded, but was flaky
Failed CI StepsTest FailuresMetrics [docs]Public APIs missing comments
Public APIs missing exports
History
To update your PR or re-run it, just comment with: cc @spong |
Summary
Migrates our existing RAG pipeline to use LangGraph, and adds tools for Knowledge Base retrieval/storage.
When the
assistantKnowledgeBaseByDefault
FF is enabled, a new branch,callAssistantGraph()
, is taken inpostActionsConnectorExecuteRoute
that exercises the LangGraph implementation. This is a drop-in replacement for the existingcallAgentExecutor()
in effort to keep adoption as clean and easy as possible.The new control flow is as follows:
postActionsConnectorExecuteRoute
->callAssistantGraph()
->getDefaultAssistantGraph()
->isStreamingEnabled ? streamGraph() : invokeGraph()
Graph creation is isolated to
getDefaultAssistantGraph()
, and execution (streaming or not) has been extracted tostreamGraph()
andinvokeGraph()
respectively. Note: Streaming currently only works withChatOpenAI
models, butSimpleChatModelStreaming
was de-risked and just need to discuss potential solutions with @stephmilovic. See comment here.DefaultAssistantGraph
To start with a predictable and piecemeal migration, our existing
agentExecutor
pipeline has been recreated in LangGraph. It consists of a single agent node, eitherOpenAIFunctionsAgent
, orStructuredChatAgent
(depending on the backing LLM), a tool executing node, and a conditional edge that routes between the two nodes until there are no more function calls chosen by the agent. This varies from our initial implementation in that multiple tool calls are now supported, so a user could ask about their alerts AND retrieve additional knowledge base information in the same response.Note
While
chat_history
has been plumbed into the graph, after discussing with @YulNaumenko we decided to wait to plumb the rest of persistence into the graph until #184485 is merged. I had already plumbed through thechatTitleGeneration
node (here), and so will just need to include initial conversation creation and append/update operations.Knowledge History & KB Tools
Knowledge History is now always added in the initial prompt for any KB documents marked as
required
, and two new tools were added for creating and recalling KB entries from within the conversation,KnowledgeBaseWriteTool
andKnowledgeBaseRetrievalTool
respectively. All three methods of storing and retrieving KB content use thekbDataClient
for access, and scopes all requests to the authenticatedUser that made the initial request.Additional Notes:
LangGraph
has been added.Checklist
Delete any items that are not applicable to this PR.