From 98bf16aa49275c7531309359f27fa3ad2f068ab6 Mon Sep 17 00:00:00 2001 From: Jesse Kornblum Date: Thu, 24 Apr 2025 15:10:06 -0700 Subject: [PATCH] Add nicer error message for agents without tools Signed-off-by: Jesse Kornblum --- src/aiq/agent/react_agent/register.py | 2 ++ src/aiq/agent/rewoo_agent/register.py | 2 ++ src/aiq/agent/tool_calling_agent/register.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/aiq/agent/react_agent/register.py b/src/aiq/agent/react_agent/register.py index ab77b4dd1..6173adcb3 100644 --- a/src/aiq/agent/react_agent/register.py +++ b/src/aiq/agent/react_agent/register.py @@ -92,6 +92,8 @@ async def react_agent_workflow(config: ReActAgentWorkflowConfig, builder: Builde # the agent can run any installed tool, simply install the tool and add it to the config file # the sample tool provided can easily be copied or changed tools = builder.get_tools(tool_names=config.tool_names, wrapper_type=LLMFrameworkEnum.LANGCHAIN) + if not tools: + raise ValueError(f"No tools specified for ReAct Agent '{config.llm_name}'") # configure callbacks, for sending intermediate steps # construct the ReAct Agent Graph from the configured llm, prompt, and tools graph: CompiledGraph = await ReActAgentGraph(llm=llm, diff --git a/src/aiq/agent/rewoo_agent/register.py b/src/aiq/agent/rewoo_agent/register.py index b3cb02224..4843a4a12 100644 --- a/src/aiq/agent/rewoo_agent/register.py +++ b/src/aiq/agent/rewoo_agent/register.py @@ -106,6 +106,8 @@ async def ReWOO_agent_workflow(config: ReWOOAgentWorkflowConfig, builder: Builde # the agent can run any installed tool, simply install the tool and add it to the config file # the sample tool provided can easily be copied or changed tools = builder.get_tools(tool_names=config.tool_names, wrapper_type=LLMFrameworkEnum.LANGCHAIN) + if not tools: + raise ValueError(f"No tools specified for ReWOO Agent '{config.llm_name}'") # construct the ReWOO Agent Graph from the configured llm, prompt, and tools graph: CompiledGraph = await ReWOOAgentGraph(llm=llm, diff --git a/src/aiq/agent/tool_calling_agent/register.py b/src/aiq/agent/tool_calling_agent/register.py index b4baddf47..faa7fe558 100644 --- a/src/aiq/agent/tool_calling_agent/register.py +++ b/src/aiq/agent/tool_calling_agent/register.py @@ -57,6 +57,8 @@ async def tool_calling_agent_workflow(config: ToolCallAgentWorkflowConfig, build # the agent can run any installed tool, simply install the tool and add it to the config file # the sample tools provided can easily be copied or changed tools = builder.get_tools(tool_names=config.tool_names, wrapper_type=LLMFrameworkEnum.LANGCHAIN) + if not tools: + raise ValueError(f"No tools specified for Tool Calling Agent '{config.llm_name}'") # some LLMs support tool calling # these models accept the tool's input schema and decide when to use a tool based on the input's relevance