trading_agent.tools.ask_user_tool
¶
The ask_user tool: puts one to four multiple-choice questions to the user, as Claude Code's question card does.
The desk does not wait. The questions are saved and shown in the web chat and on Telegram, and the user's answers arrive later as a new message.
Typical usage example:
tool = AskUserTool(store, event_bus, 'main')
QuestionOption
¶
Bases: BaseModel
One choice in a question.
Attributes:
| Name | Type | Description |
|---|---|---|
label |
str
|
The short text on the choice, one to five words. |
description |
str
|
What choosing it means, or its trade-offs. |
preview |
str | None
|
Optional Markdown shown beside the choices when this one is highlighted, such as a table of levels or an order ticket. |
Question
¶
Bases: BaseModel
One question with its choices.
Attributes:
| Name | Type | Description |
|---|---|---|
question |
str
|
The full question, ending with a question mark. |
header |
str
|
A tag of at most 12 characters naming the topic, such as "Stop loss". |
options |
list[QuestionOption]
|
Two to four choices; an "Other" box for a free answer is added automatically. |
multi_select |
bool
|
True when more than one choice may be picked. |
AskUserArguments
¶
Bases: BaseModel
The arguments of ask_user.
Attributes:
| Name | Type | Description |
|---|---|---|
questions |
list[Question]
|
One to four questions, shown together. |
AskUserTool
¶
Bases: Tool
Saves and shows the desk's questions to the user.
Creates the tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
UserRequestStore
|
Where the request is saved. |
required |
event_bus
|
EventBus
|
Where it is published for the web page and Telegram. |
required |
desk_name
|
str
|
The desk asking. |
required |
Source code in src/trading_agent/tools/ask_user_tool.py
run
async
¶
Saves the questions and publishes them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arguments
|
AskUserArguments
|
The questions. |
required |
Returns:
| Type | Description |
|---|---|
ToolResult
|
The request's identifier and what happens next. |