Skip to content

trading_agent.tools.browser_tabs_tool

The browser_tabs tool: lists, switches between and closes tabs.

Typical usage example:

tool = BrowserTabsTool(session)

BrowserTabsArguments

Bases: BaseModel

The arguments of browser_tabs.

Attributes:

Name Type Description
action Literal['list', 'switch', 'close']

"list" to see the tabs, "switch" to make one current, "close" to close one.

tab int | None

The tab's number from the list, for "switch" and "close".

BrowserTabsTool

BrowserTabsTool(session)

Bases: BrowserTool

Manages tabs.

Source code in src/trading_agent/tools/browser_tool.py
def __init__(self, session: browser_session_module.BrowserSession):
    """Creates the tool.

    Args:
        session (browser_session_module.BrowserSession): The desk's browser.
    """
    self._session = session

run async

run(arguments)

Runs the tab action.

Parameters:

Name Type Description Default
arguments BrowserTabsArguments

The action and tab number.

required

Returns:

Type Description
ToolResult

The tabs after the action, or an error.

Source code in src/trading_agent/tools/browser_tabs_tool.py
async def run(self, arguments: BrowserTabsArguments) -> tool.ToolResult:
    """Runs the tab action.

    Args:
        arguments (BrowserTabsArguments): The action and tab number.

    Returns:
        tool.ToolResult: The tabs after the action, or an error.
    """
    return await self._text_result(
        self._session.tabs(arguments.action, arguments.tab)
    )