Skip to content

[Bug] LangGraph agents fail with zero tools #231

@bboynton97

Description

@bboynton97

If you generate an agent and dont give it any tools, it fails with result

Error code: 400 - {'error': {'message': "Invalid 'tools': empty array. Expected an array with minimum length 1, but got an empty array instead.", 'type': 'invalid_request_error', 'param': 'tools', 'code': 'empty_array'}}

This is because we are passing an empty array into the node

@agentstack.agent
def translator(self, state: State):
    agent_config = agentstack.get_agent('translator')
    messages = ChatPromptTemplate.from_messages([
        ("user", agent_config.prompt), 
    ])
    messages = messages.format_messages(**state['inputs'])
    agent = ChatOpenAI(model=agent_config.model)
    agent = agent.bind_tools([])        #   <---------------------------
    response = agent.invoke(
        messages + state['messages'],
    )
    return {'messages': [response, ]}

We should comment this line out when no tools are present and uncomment when a tool is added

✅ At the moment you can solve this by commenting out or removing the .bind_tools() line

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions