Skip to content

trading_agent.tools.propose_file_change_tool

A tool with which a desk proposes a change to one of the user's files.

The desk cannot edit the user's files. It sends the complete new text and a reason, and the user accepts or rejects it with trading-agent proposals.

Typical usage example:

tool = ProposeFileChangeTool(store, 'main')

ProposeFileChangeArguments

Bases: BaseModel

The arguments of propose_file_change.

Attributes:

Name Type Description
file_name Literal['Agents.md', 'User.md', 'TradingRules.md', 'Persona.md']

Which of the user's files to change.

content str

The complete new text of the file.

reason str

Why the change is needed, in one or two sentences.

ProposeFileChangeTool

ProposeFileChangeTool(store, desk_name)

Bases: Tool

Saves a proposed new version of one of the user's files.

Creates the tool for one desk.

Parameters:

Name Type Description Default
store ProposalStore

Where proposals are saved.

required
desk_name str

The desk using the tool.

required
Source code in src/trading_agent/tools/propose_file_change_tool.py
def __init__(self, store: proposal_store.ProposalStore, desk_name: str):
    """Creates the tool for one desk.

    Args:
        store (proposal_store.ProposalStore): Where proposals are saved.
        desk_name (str): The desk using the tool.
    """
    self._store = store
    self._desk_name = desk_name

run async

run(arguments)

Saves the proposal.

Parameters:

Name Type Description Default
arguments ProposeFileChangeArguments

The file, its new text and the reason.

required

Returns:

Type Description
ToolResult

The new proposal's id and how the user accepts it.

Source code in src/trading_agent/tools/propose_file_change_tool.py
async def run(
    self, arguments: ProposeFileChangeArguments
) -> tool.ToolResult:
    """Saves the proposal.

    Args:
        arguments (ProposeFileChangeArguments): The file, its new text and the reason.

    Returns:
        tool.ToolResult: The new proposal's id and how the user accepts it.
    """
    proposal = self._store.create(
        self._desk_name,
        arguments.file_name,
        arguments.content,
        arguments.reason,
    )
    return tool.ToolResult.success(
        f'Saved proposal {proposal.proposal_id} for {arguments.file_name}. The user can review it with: trading-agent proposals show {proposal.proposal_id}, and accept it with: trading-agent proposals accept {proposal.proposal_id}'
    )