Skip to content

trading_agent.tools.skill_archive_tool

The skill_archive tool: takes one of the desk's own skills out of use without deleting it.

Typical usage example:

tool = SkillArchiveTool(writer)

SkillArchiveArguments

Bases: BaseModel

The arguments of skill_archive.

Attributes:

Name Type Description
name str

The skill to archive, which must be one of your own.

reason str

Why, for the skill ledger, such as "merged into gap-playbook".

SkillArchiveTool

SkillArchiveTool(writer)

Bases: Tool

Archives one of the desk's own skills.

Creates the tool.

Parameters:

Name Type Description Default
writer SkillWriter

Writes the desk's skills.

required
Source code in src/trading_agent/tools/skill_archive_tool.py
def __init__(self, writer: skill_writer_module.SkillWriter):
    """Creates the tool.

    Args:
        writer (skill_writer_module.SkillWriter): Writes the desk's skills.
    """
    self._writer = writer

run async

run(arguments)

Archives the skill in a worker thread.

Parameters:

Name Type Description Default
arguments SkillArchiveArguments

The skill and the reason.

required

Returns:

Type Description
ToolResult

A confirmation, or why nothing changed.

Source code in src/trading_agent/tools/skill_archive_tool.py
async def run(self, arguments: SkillArchiveArguments) -> tool.ToolResult:
    """Archives the skill in a worker thread.

    Args:
        arguments (SkillArchiveArguments): The skill and the reason.

    Returns:
        tool.ToolResult: A confirmation, or why nothing changed.
    """
    try:
        await asyncio.to_thread(
            self._writer.archive,
            arguments.name,
            arguments.reason,
        )
    except skill_writer_module.SkillWriteError as error:
        return tool.ToolResult.error(str(error))
    return tool.ToolResult.success(f'Archived skill {arguments.name}.')