Skip to content

Commit eef6933

Browse files
authored
Add nicer error message for agents without tools (#146)
Adds a check for empty tools being used in agent configs. If we don't find any tools, raises an exception with the name of the llm in question to make debugging easier. Sample output: ``` aiq run --config_file workflow.yaml --input foo.msg [...] ValueError: No tools specified for ReAct Agent 'email_extraction_llm' Error: No tools specified for ReAct Agent 'email_extraction_llm' ``` Closes #145 ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/AgentIQ/blob/develop/docs/source/advanced/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. Authors: - Jesse Kornblum (https://github.com/jkornblum-nv) Approvers: - Yuchen Zhang (https://github.com/yczhang-nv) URL: #146
1 parent eb832e3 commit eef6933

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

‎src/aiq/agent/react_agent/register.py

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ async def react_agent_workflow(config: ReActAgentWorkflowConfig, builder: Builde
9292
# the agent can run any installed tool, simply install the tool and add it to the config file
9393
# the sample tool provided can easily be copied or changed
9494
tools = builder.get_tools(tool_names=config.tool_names, wrapper_type=LLMFrameworkEnum.LANGCHAIN)
95+
if not tools:
96+
raise ValueError(f"No tools specified for ReAct Agent '{config.llm_name}'")
9597
# configure callbacks, for sending intermediate steps
9698
# construct the ReAct Agent Graph from the configured llm, prompt, and tools
9799
graph: CompiledGraph = await ReActAgentGraph(llm=llm,

‎src/aiq/agent/rewoo_agent/register.py

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ async def ReWOO_agent_workflow(config: ReWOOAgentWorkflowConfig, builder: Builde
106106
# the agent can run any installed tool, simply install the tool and add it to the config file
107107
# the sample tool provided can easily be copied or changed
108108
tools = builder.get_tools(tool_names=config.tool_names, wrapper_type=LLMFrameworkEnum.LANGCHAIN)
109+
if not tools:
110+
raise ValueError(f"No tools specified for ReWOO Agent '{config.llm_name}'")
109111

110112
# construct the ReWOO Agent Graph from the configured llm, prompt, and tools
111113
graph: CompiledGraph = await ReWOOAgentGraph(llm=llm,

‎src/aiq/agent/tool_calling_agent/register.py

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ async def tool_calling_agent_workflow(config: ToolCallAgentWorkflowConfig, build
5757
# the agent can run any installed tool, simply install the tool and add it to the config file
5858
# the sample tools provided can easily be copied or changed
5959
tools = builder.get_tools(tool_names=config.tool_names, wrapper_type=LLMFrameworkEnum.LANGCHAIN)
60+
if not tools:
61+
raise ValueError(f"No tools specified for Tool Calling Agent '{config.llm_name}'")
6062

6163
# some LLMs support tool calling
6264
# these models accept the tool's input schema and decide when to use a tool based on the input's relevance

0 commit comments

Comments
 (0)