Skip to content

trading_agent.tools.bash_run_tool

The bash_run tool: runs one command in the desk's terminal and waits for it.

Typical usage example:

tool = BashRunTool(session)

BashRunTool

BashRunTool(session)

Bases: BashTool

Runs one command and returns its output.

Creates the tool, with a time limit just above the terminal's own.

Parameters:

Name Type Description Default
session BashSession

The desk's terminal.

required
Source code in src/trading_agent/tools/bash_run_tool.py
def __init__(self, session: bash_session_module.BashSession):
    """Creates the tool, with a time limit just above the terminal's own.

    Args:
        session (bash_session_module.BashSession): The desk's terminal.
    """
    super().__init__(session)
    self.timeout_seconds = session.timeout_seconds + _TIMEOUT_MARGIN_SECONDS

run async

run(arguments)

Runs the command.

Parameters:

Name Type Description Default
arguments CommandArguments

The command.

required

Returns:

Type Description
ToolResult

Its output and exit status.

Source code in src/trading_agent/tools/bash_run_tool.py
async def run(
    self,
    arguments: bash_command_arguments.CommandArguments,
) -> tool.ToolResult:
    """Runs the command.

    Args:
        arguments (bash_command_arguments.CommandArguments): The command.

    Returns:
        tool.ToolResult: Its output and exit status.
    """
    return self._result_from(await self._session.run(arguments.command))

close async

close()

Stops the terminal when the desk stops.

Source code in src/trading_agent/tools/bash_run_tool.py
async def close(self) -> None:
    """Stops the terminal when the desk stops."""
    await self._session.close()