Skip to main content
Base Node Node inspector for a Python Code Tool node

Parameters

Tool Name
string
default:"example_tool"
required
Name to register for the generated tool.
Tool Description
string
default:"Example tool created from Python code."
required
Description to register for the generated tool.
Source Code
string
required
Python code defining an async python function. This coroutine will be executed when this tool is invoked by the agent. The default value for this parameter is:
Default tool function
async def tool(wrapper: "RunContextWrapper", text: str):
    return {"echo": text}
The first argument in the function signature must be of type RunContextWrapper. You can use wrapper.context.<NodeName> to access upstream node outputs. For example:
Accessing upstream node outputs
async def tool(wrapper: "RunContextWrapper", customer_id: str) -> dict:
    customer_data = wrapper.context.Customer_Data.output
    return customer_data[customer_id]
In the above example, Customer_Data is the name of an upstream node that produces a dictionary mapping customer IDs to customer information.

Inputs

This node has no inputs.

Outputs

Output
tool
Generated tool configuration for the Agent node.