Skip to content

trading_agent.tools.bash_background_tool

The bash_background tool: starts a long command and returns at once.

Typical usage example:

tool = BashBackgroundTool(session)

BashBackgroundTool

BashBackgroundTool(session)

Bases: BashTool

Starts a command that keeps running after the call returns.

Source code in src/trading_agent/tools/bash_tool.py
def __init__(self, session: bash_session_module.BashSession):
    """Creates the tool.

    Args:
        session (bash_session_module.BashSession): The desk's terminal.
    """
    self._session = session

run async

run(arguments)

Starts the job.

Parameters:

Name Type Description Default
arguments CommandArguments

The command.

required

Returns:

Type Description
ToolResult

The job id.

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

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

    Returns:
        tool.ToolResult: The job id.
    """
    job_id = await self._session.run_in_background(arguments.command)
    return tool.ToolResult.success(
        f'Started background job {job_id}. Check it with bash_check.'
    )