Error calling custom tool - smolagents library

Created a custom tool using smolagents library:

# Create custom tool 
@tool
def check_model_exists(model_name: str) -> str:
    """
    Tool to check if specific model exists in repository

    Args:
        model_name: The model to be searched for in the local repository
    """
    
    return "Model exists" #dummy return

When invoking this tool using agent.run(query), I get the error message:

Error in tool call execution: check_model_exists() got an unexpected keyword argument ‘sanitize_inputs_outputs’
You should only use this tool with a correct input.
As a reminder, this tool’s description is the following:

  • check_model_exists: Tool to check if specific model exists in ollama repository
    Takes inputs: {‘model_name’: {‘type’: ‘string’, ‘description’: ‘The model to be searched for in the local ollama
    repository’}}
    Returns an output of type: string

How can I resolve this? The library seems to be inserting ‘sanitize_inputs_outputs’ automatically

2 Likes

Did you end up figuring this out? My previously working app has started throwing this error on delegation :\

Error in calling team member: MultiStepAgent.run() got an unexpected keyword argument 'sanitize_inputs_outputs'
You should only ask this team member with a correct request.
As a reminder, this team member's description is the following:
<smolagents.agents.ManagedAgent object at 0x140350d90>
1 Like

No, it’s still giving this error, so I’ve left the library alone until it’s fixed

1 Like

It looks like there are no issues, so I wonder if it’s a problem with the code or a problem specific to the environment…:thinking:

Added a pull request which addresses the issue: Don't pass sanitize_inputs_outputs=True to managed agents by grrowl · Pull Request #85 · huggingface/smolagents · GitHub

1 Like

@aamanlambda could you provide more detail on your error?
I tried:

from smolagents import tool
@tool
def check_model_exists(model_name: str) -> str:
    """
    Tool to check if specific model exists in repository

    Args:
        model_name: The model to be searched for in the local repository
    """
    
    return "Model exists" #dummy return

from smolagents import tool, CodeAgent, HfApiModel
agent = CodeAgent(tools=[check_model_exists], model=HfApiModel(), add_base_tools=True)
agent.run("Does the model 'a' exist in repository?")

it worked fine!

1 Like

i am having the same issue. i logged it and i am sending and receiving string so idk what the issue is. the function works inside my agent since it receives the stuff but smolagents acts like it failed so it doesnt execute the output from the function in my agent.

1 Like