Skip to content

trading_agent.tools.skill_create_tool

The skill_create tool: writes down a procedure as one of the desk's own skills.

Typical usage example:

tool = SkillCreateTool(writer)

SkillCreateArguments

Bases: BaseModel

The arguments of skill_create.

Attributes:

Name Type Description
name str

The new skill's name: lower-case letters, digits and hyphens.

description str

One or two sentences saying when to use it; this is what the skills index shows.

instructions str

The procedure in Markdown, as numbered steps with the tools to use and what to check.

required_programs list[str]

Programs the skill needs, such as python3.

required_environment list[str]

Environment variables the skill needs.

reason str

Why the skill is worth keeping, for the skill ledger.

SkillCreateTool

SkillCreateTool(writer)

Bases: Tool

Creates 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_create_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)

Writes the skill in a worker thread, because the snapshot runs git.

Parameters:

Name Type Description Default
arguments SkillCreateArguments

The skill.

required

Returns:

Type Description
ToolResult

Where the skill was written, or why it was refused.

Source code in src/trading_agent/tools/skill_create_tool.py
async def run(self, arguments: SkillCreateArguments) -> tool.ToolResult:
    """Writes the skill in a worker thread, because the snapshot runs git.

    Args:
        arguments (SkillCreateArguments): The skill.

    Returns:
        tool.ToolResult: Where the skill was written, or why it was refused.
    """
    try:
        await asyncio.to_thread(
            self._writer.create,
            arguments.name,
            arguments.description,
            arguments.instructions,
            arguments.required_programs,
            arguments.required_environment,
            arguments.reason,
        )
    except skill_writer_module.SkillWriteError as error:
        return tool.ToolResult.error(str(error))
    return tool.ToolResult.success(
        f'Created skill {arguments.name}. It is in the skills index from your next turn.'
    )