trading_agent.agent.prompt_builder
¶
Builds a desk's system prompt from the workspace files.
The prompt is read fresh before every turn, so an edit to a file reaches the desk on its next turn. It holds only slow-changing text, so that it stays identical between turns and the model's prompt cache keeps working; the time and the trigger go in the user message instead.
Typical usage example:
builder = PromptBuilder(layout, 'main', 'dry_run') prompt = builder.build() prompt.text, prompt.fingerprint
SystemPrompt
dataclass
¶
One built prompt.
Attributes:
| Name | Type | Description |
|---|---|---|
text |
str
|
The prompt. |
fingerprint |
str
|
A short hash of the text, which changes whenever the text does. |
PromptBuilder
¶
PromptBuilder(layout, desk_name, mode, skill_library=None, mcp_manager=None, subagent_library=None, other_desks=())
Assembles one desk's prompt.
Creates the builder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layout
|
WorkspaceLayout
|
Where the files are. |
required |
desk_name
|
str
|
The desk the prompt is for. |
required |
mode
|
str
|
"dry_run" or "live", stated in the prompt. |
required |
skill_library
|
SkillLibrary | None
|
The desk's skills, listed as an index at the end, or None for no index. |
None
|
mcp_manager
|
McpClientManager | None
|
The MCP connections, whose tool names are listed last, or None. |
None
|
subagent_library
|
SubagentLibrary | None
|
The subagents the desk can delegate to, listed after the skills, or None. |
None
|
other_desks
|
Sequence[str]
|
The other desks sharing the account, named in the header. |
()
|
Source code in src/trading_agent/agent/prompt_builder.py
build
¶
Reads the files and assembles the prompt.
Returns:
| Type | Description |
|---|---|
SystemPrompt
|
The prompt and its fingerprint. |