[tools] priority and how does it work with existing CompiledStateGraph? #27

Closed
opened 2026-02-16 08:19:29 -05:00 by yindo · 4 comments
Owner

Originally created by @khteh on GitHub (Aug 24, 2025).

How does the deepagent prioritize the tools usage? WIll the top-level tools override the tools of the subagents? For example, if I have a few subagents which perform RAG operations on different categories of corpora, Email, Graph DB, internal domain-based documents for instance, will the top-level internet-search tool be prioritized to be used to answer the query instead of the more specific answer expected from the individual domain-specific subagents?

Is this going to be the preferred architecture in the future? How does it work with the existing CompiledStateGraph without having to refactor / migrate my existing code?

Originally created by @khteh on GitHub (Aug 24, 2025). How does the deepagent prioritize the tools usage? WIll the top-level tools override the tools of the subagents? For example, if I have a few subagents which perform RAG operations on different categories of corpora, Email, Graph DB, internal domain-based documents for instance, will the top-level `internet-search` tool be prioritized to be used to answer the query instead of the more specific answer expected from the individual domain-specific subagents? Is this going to be the preferred architecture in the future? How does it work with the existing `CompiledStateGraph` without having to refactor / migrate my existing code?
yindo added the question label 2026-02-16 08:19:29 -05:00
yindo closed this issue 2026-02-16 08:19:29 -05:00
Author
Owner

@hwchase17 commented on GitHub (Sep 7, 2025):

as for what is prioritized - that gets specified via prompting

how would you want to use CompiledStateGraph with this?

@hwchase17 commented on GitHub (Sep 7, 2025): as for what is prioritized - that gets specified via prompting how would you want to use CompiledStateGraph with this?
Author
Owner

@khteh commented on GitHub (Sep 8, 2025):

I have existing applications, some built using ReAct Agent create_react_agent and some using manual CompiledStateGraph. When I included internet search tool in LLM binding as well as input parameter to create_react_agent, the internet search tool is always used to provide the answer instead of using the internal document vectors and Graph DB. Therefore, I removed the internet search tool from the tools list. How would create_deep_agent be different in this case?

how would you want to use CompiledStateGraph with this?

That's exactly my question. For example,

tool_graph = StateGraph(MyRAGState)
self._graph = tool_graph.compile(name=self._graphName, cache=InMemoryCache())

main_graph = StateGraph(MyRAGState)
main_graph.add_node("EmailTools", ToolNode([email_processing_tool]), cache_policy = cache_policy)
self._agent = main_graph.compile(name=self._agentName, cache=InMemoryCache(), store = self._store)

email_processing_tool, which is used by main_graph, needs to access tool_graph. This is accessed through RunnableConfig and therefore, main_graph is invoked async for step in self._agent.with_config({"graph": self._graph ...). This is quite messy. How would using deepagent` be different in this use case?

@khteh commented on GitHub (Sep 8, 2025): I have existing applications, some built using ReAct Agent `create_react_agent` and some using manual `CompiledStateGraph`. When I included internet search tool in LLM binding as well as input parameter to `create_react_agent`, the internet search tool is always used to provide the answer instead of using the internal document vectors and Graph DB. Therefore, I removed the internet search tool from the tools list. How would `create_deep_agent` be different in this case? > how would you want to use CompiledStateGraph with this? That's exactly my question. For example, ``` tool_graph = StateGraph(MyRAGState) self._graph = tool_graph.compile(name=self._graphName, cache=InMemoryCache()) main_graph = StateGraph(MyRAGState) main_graph.add_node("EmailTools", ToolNode([email_processing_tool]), cache_policy = cache_policy) self._agent = main_graph.compile(name=self._agentName, cache=InMemoryCache(), store = self._store) ``` `email_processing_tool`, which is used by `main_graph`, needs to access `tool_graph`. This is accessed through `RunnableConfig` and therefore, `main_graph is invoked `async for step in self._agent.with_config({"graph": self._graph ...)`. This is quite messy. How would using `deepagent` be different in this use case?
Author
Owner

@nhuang-lc commented on GitHub (Sep 18, 2025):

I don't know that it would be different, but I'd recommend that you wrap your existing graphs (whether written with create_react_agent, or a more custom StateGraph) in tool functions.

Then you can provide these tools to the Deep Agent - prompting should be sufficient to direct the agent to choose the right tools, whether they are RAG, websearch, or others in different scenarios.

@nhuang-lc commented on GitHub (Sep 18, 2025): I don't know that it would be different, but I'd recommend that you wrap your existing graphs (whether written with create_react_agent, or a more custom StateGraph) in tool functions. Then you can provide these tools to the Deep Agent - prompting should be sufficient to direct the agent to choose the right tools, whether they are RAG, websearch, or others in different scenarios.
Author
Owner

@khteh commented on GitHub (Sep 18, 2025):

How to keep the CompiledStateGraph in the stateless @tool function?

@khteh commented on GitHub (Sep 18, 2025): How to keep the `CompiledStateGraph` in the stateless `@tool` function?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagents#27