Skip to content

trading_agent.tools.present_plan_tool

The present_plan tool: shows the user a plan to approve before the desk acts on it, as Claude Code's plan approval does.

The desk does not wait. The plan is saved and shown in the web chat and on Telegram, and the user's decision arrives later as a new message.

Typical usage example:

tool = PresentPlanTool(store, event_bus, 'main')

PresentPlanArguments

Bases: BaseModel

The arguments of present_plan.

Attributes:

Name Type Description
title str

A short name for the plan, such as "Monday pre-market plan".

plan str

The plan in Markdown: what you will do, with levels, sizes and the conditions that would change it.

PresentPlanTool

PresentPlanTool(store, event_bus, desk_name)

Bases: Tool

Saves and shows the desk's plan to the user for approval.

Creates the tool.

Parameters:

Name Type Description Default
store UserRequestStore

Where the request is saved.

required
event_bus EventBus

Where it is published for the web page and Telegram.

required
desk_name str

The desk presenting the plan.

required
Source code in src/trading_agent/tools/present_plan_tool.py
def __init__(
    self,
    store: user_request_store_module.UserRequestStore,
    event_bus: event_bus_module.EventBus,
    desk_name: str,
):
    """Creates the tool.

    Args:
        store (user_request_store_module.UserRequestStore): Where the request is saved.
        event_bus (event_bus_module.EventBus): Where it is published for the web page and Telegram.
        desk_name (str): The desk presenting the plan.
    """
    self._store = store
    self._event_bus = event_bus
    self._desk_name = desk_name

run async

run(arguments)

Saves the plan and publishes it.

Parameters:

Name Type Description Default
arguments PresentPlanArguments

The plan.

required

Returns:

Type Description
ToolResult

The request's identifier and what happens next.

Source code in src/trading_agent/tools/present_plan_tool.py
async def run(self, arguments: PresentPlanArguments) -> tool.ToolResult:
    """Saves the plan and publishes it.

    Args:
        arguments (PresentPlanArguments): The plan.

    Returns:
        tool.ToolResult: The request's identifier and what happens next.
    """
    request = user_request_module.UserRequest.new(
        self._desk_name,
        user_request_module.PLAN,
        arguments.model_dump(),
    )
    self._store.save(request)
    self._event_bus.publish(
        event_module.Event.now(
            event_module.EventKind.USER_REQUEST,
            self._desk_name,
            request.to_json_dictionary(),
        )
    )
    return tool.ToolResult.success(
        f'The plan was sent to the user as request {request.request_id}. Do not act on it yet, and do not wait: end this turn. The decision will arrive as a new message naming the request.'
    )