trading_agent.workspace.proposal_store
¶
Proposed changes to the user's files, waiting for the user to accept or reject them.
The agent cannot edit Agents.md, User.md, TradingRules.md or a Persona.md. It writes a proposal instead: the complete new text of one file and the reason. Accepting a proposal keeps a copy of the file it replaces.
Typical usage example:
store = ProposalStore(layout) proposal = store.create('main', 'User.md', new_text, 'Filled in from the interview') store.accept(proposal.proposal_id)
ProposalError
¶
Bases: ValueError
A proposal does not exist, or is not pending.
Proposal
dataclass
¶
One proposed change.
Attributes:
| Name | Type | Description |
|---|---|---|
proposal_id |
str
|
The identifier the user types to accept or reject it. |
desk |
str
|
The desk that proposed it. |
file_name |
str
|
The user file it would replace. |
content |
str
|
The complete new text. |
reason |
str
|
Why the desk proposes it. |
created_at |
str
|
When it was proposed, as ISO 8601 text in UTC. |
status |
str
|
"pending", "accepted" or "rejected". |
from_json_dictionary
classmethod
¶
Reads a proposal saved by to_json_dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dictionary
|
dict[str, Any]
|
The saved fields. |
required |
Returns:
| Type | Description |
|---|---|
Proposal
|
The proposal. |
Source code in src/trading_agent/workspace/proposal_store.py
to_json_dictionary
¶
Converts the proposal to a dictionary that json.dumps can write.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Every field. |
ProposalStore
¶
Saves, lists, accepts and rejects proposals.
Creates the store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layout
|
WorkspaceLayout
|
The workspace whose desks' proposals folders hold the proposals. |
required |
Source code in src/trading_agent/workspace/proposal_store.py
create
¶
Saves a new pending proposal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
desk_name
|
str
|
The desk proposing the change. |
required |
file_name
|
str
|
One of the user's files. |
required |
content
|
str
|
The complete new text. |
required |
reason
|
str
|
Why. |
required |
Returns:
| Type | Description |
|---|---|
Proposal
|
The saved proposal. |
Raises:
| Type | Description |
|---|---|
ValueError
|
The file is not one of the user's files. |
Source code in src/trading_agent/workspace/proposal_store.py
all
¶
Every proposal from every desk, oldest first.
Returns:
| Type | Description |
|---|---|
list[Proposal]
|
The proposals. |
Source code in src/trading_agent/workspace/proposal_store.py
get
¶
Finds one proposal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proposal_id
|
str
|
Its identifier. |
required |
Returns:
| Type | Description |
|---|---|
Proposal
|
The proposal. |
Raises:
| Type | Description |
|---|---|
ProposalError
|
No proposal has that identifier. |
Source code in src/trading_agent/workspace/proposal_store.py
difference
¶
Shows what accepting a proposal would change, as a unified diff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proposal_id
|
str
|
Its identifier. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The diff, with "-" lines removed and "+" lines added. |
Source code in src/trading_agent/workspace/proposal_store.py
accept
¶
Replaces the user file with the proposed text, keeping a copy of the old one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proposal_id
|
str
|
Its identifier. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The file that was replaced. |
Raises:
| Type | Description |
|---|---|
ProposalError
|
The proposal does not exist or is not pending. |
Source code in src/trading_agent/workspace/proposal_store.py
reject
¶
Marks a proposal as rejected without changing any file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proposal_id
|
str
|
Its identifier. |
required |
Raises:
| Type | Description |
|---|---|
ProposalError
|
The proposal does not exist or is not pending. |