deepagents icon indicating copy to clipboard operation
deepagents copied to clipboard

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

Open khteh opened this issue 4 months ago • 4 comments

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?

khteh avatar Aug 24 '25 06:08 khteh

as for what is prioritized - that gets specified via prompting

how would you want to use CompiledStateGraph with this?

hwchase17 avatar Sep 07 '25 11:09 hwchase17

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 avatar Sep 08 '25 08:09 khteh

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 avatar Sep 18 '25 21:09 nhuang-lc

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

khteh avatar Sep 19 '25 02:09 khteh