agents.planning.rewoo.models.tool_step

Tool Step Model - Generic step that validates against a tool list.

A concrete step implementation that works with LangChain tools and validates: - Tool exists in provided tool list - Tool arguments match tool schema - Tool can be executed with given parameters

Classes

ToolStep

A step that executes a specific tool with validated arguments.

Functions

create_tool_steps_from_plan(tool_plan, available_tools)

Create a list of ToolSteps from a plan description.

validate_tool_compatibility(tools)

Validate a list of tools for compatibility issues.

Module Contents

class agents.planning.rewoo.models.tool_step.ToolStep

Bases: agents.planning.rewoo.models.steps.AbstractStep

A step that executes a specific tool with validated arguments.

can_execute(completed_steps)

Check if this step can execute.

Parameters:

completed_steps (set[str])

Return type:

bool

clear_tool_args()

Clear all tool arguments.

Return type:

None

classmethod create_from_tool(tool, tool_args, available_tools, description=None, **kwargs)

Factory method to create ToolStep from a tool instance.

Parameters:
  • tool (langchain_core.tools.BaseTool)

  • tool_args (dict[str, Any])

  • available_tools (list[langchain_core.tools.BaseTool])

  • description (str | None)

Return type:

ToolStep

execute(context)

Execute the tool with the provided arguments.

Parameters:

context (dict[str, Any])

Return type:

Any

get_tool_info()

Get comprehensive tool information.

Return type:

dict[str, Any]

update_tool_args(**kwargs)

Update tool arguments and revalidate.

Return type:

None

validate_tool_exists_and_args()

Validate tool exists and arguments are correct.

Return type:

ToolStep

classmethod validate_tool_name(v, info)

Validate tool name exists in available tools.

Parameters:

v (str)

Return type:

str

classmethod validate_tools_not_empty(v)

Validate tools list is not empty.

Parameters:

v (list[langchain_core.tools.BaseTool])

Return type:

list[langchain_core.tools.BaseTool]

property is_tool_valid: bool

Whether the tool setup is valid.

Return type:

bool

property optional_args: list[str]

Optional arguments for the selected tool.

Return type:

list[str]

property required_args: list[str]

Required arguments for the selected tool.

Return type:

list[str]

property selected_tool: langchain_core.tools.BaseTool | None

The selected tool instance.

Return type:

langchain_core.tools.BaseTool | None

property tool_names: list[str]

List of available tool names.

Return type:

list[str]

property tool_schema: dict[str, Any] | None

Schema of the selected tool.

Return type:

dict[str, Any] | None

agents.planning.rewoo.models.tool_step.create_tool_steps_from_plan(tool_plan, available_tools)

Create a list of ToolSteps from a plan description.

Parameters:
  • tool_plan (list[dict[str, Any]])

  • available_tools (list[langchain_core.tools.BaseTool])

Return type:

list[ToolStep]

agents.planning.rewoo.models.tool_step.validate_tool_compatibility(tools)

Validate a list of tools for compatibility issues.

Parameters:

tools (list[langchain_core.tools.BaseTool])

Return type:

dict[str, Any]