Skip to content

Question: CodeAgent's remote executor never propagates non-default initialization parameters in tools? #1886

@sadaisystems

Description

@sadaisystems

Based on my (very limited) understanding of the inner workings of the mechanism of passing tools as code to remote executors, I derive that whatever params you specify at init, you seem to be always instantiating a tool with default params.

In the function used by remote executors to pass tools:

# in get_tools_definition_code, used in RemotePythonExecutor.send_tools
# line 1339
tool_code = instance_to_source(tool, base_cls=Tool)
tool_code = tool_code.replace("from smolagents.tools import Tool", "") 
tool_code += f"\n\n{tool.name} = {tool.__class__.__name__}()\n" 

The last line always instantiates the tool with its default params and will (presumably) raise an error if there at least one parameter that should always be explicitly set.

If that's by design, how do i then use tools with custom resources that require instantiation (like an api client) or how do i change default init params of the tool?

Am i missing something?

Appreciate any input!

Metadata

Metadata

Assignees

No one assigned

    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