# Error calling custom tool - smolagents library

**URL:** <https://discuss.huggingface.co/t/error-calling-custom-tool-smolagents-library/133879>\
**Category:** Beginners\
**Created:** [January 1, 2025, 7:58pm UTC](https://discuss.huggingface.co/t/error-calling-custom-tool-smolagents-library/133879 "2025-01-01T19:58:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aamanlamba](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/aamanlamba/32/38458_2.png) [@aamanlamba](https://discuss.huggingface.co/u/aamanlamba)\
**Post date:** [January 1, 2025, 7:58pm UTC](https://discuss.huggingface.co/t/error-calling-custom-tool-smolagents-library/133879/1 "2025-01-01T19:58:02Z")

</div>

Created a custom tool using smolagents library:

```auto
# 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

---

<div class="post-metadata">

**Author:** ![grrowl](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/grrowl/32/38660_2.png) [@grrowl](https://discuss.huggingface.co/u/grrowl)\
**Post date:** [January 6, 2025, 1:25am UTC](https://discuss.huggingface.co/t/error-calling-custom-tool-smolagents-library/133879/2 "2025-01-06T01:25:17Z")

</div>

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

```auto
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>

```

---

<div class="post-metadata">

**Author:** ![aamanlamba](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/aamanlamba/32/38458_2.png) [@aamanlamba](https://discuss.huggingface.co/u/aamanlamba)\
**Post date:** [January 6, 2025, 2:47am UTC](https://discuss.huggingface.co/t/error-calling-custom-tool-smolagents-library/133879/3 "2025-01-06T02:47:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [January 6, 2025, 3:16am UTC](https://discuss.huggingface.co/t/error-calling-custom-tool-smolagents-library/133879/4 "2025-01-06T03:16:26Z")

</div>

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…🤔

> **[Issues · huggingface/smolagents](https://github.com/huggingface/smolagents/issues)**
>
> 🤗 smolagents: a barebones library for agents. Agents write python code to call tools and orchestrate other agents. - Issues · huggingface/smolagents

---

<div class="post-metadata">

**Author:** ![grrowl](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/grrowl/32/38660_2.png) [@grrowl](https://discuss.huggingface.co/u/grrowl)\
**Post date:** [January 6, 2025, 5:10pm UTC](https://discuss.huggingface.co/t/error-calling-custom-tool-smolagents-library/133879/5 "2025-01-06T17:10:28Z")

</div>

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](https://github.com/huggingface/smolagents/pull/85)

---

<div class="post-metadata">

**Author:** ![m-ric](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/m-ric/32/27267_2.png) [@m-ric](https://discuss.huggingface.co/u/m-ric)\
**Post date:** [January 6, 2025, 5:41pm UTC](https://discuss.huggingface.co/t/error-calling-custom-tool-smolagents-library/133879/6 "2025-01-06T17:41:22Z")

</div>

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

```auto
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!

---

<div class="post-metadata">

**Author:** ![grasshopco](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/grasshopco/32/39245_2.png) [@grasshopco](https://discuss.huggingface.co/u/grasshopco)\
**Post date:** [January 16, 2025, 3:39am UTC](https://discuss.huggingface.co/t/error-calling-custom-tool-smolagents-library/133879/7 "2025-01-16T03:39:37Z")

</div>

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.
