mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-09 22:10:57 +08:00
feat(agent): defaults-first prompts and one-shot creation flows
- system prompt (zh+en): finish-the-work-then-report rule — chain tools in the current turn, never promise background work; prefill industry-standard defaults instead of interrogating field by field, batch any unavoidable questions into one - manage_strategy tool description: create only needs name, omitted config merges from the default template, one-shot summary + confirmed=true flow - manage_trader tool description: resolve exchange/model/strategy bindings via list tools instead of asking the user for IDs
This commit is contained in:
@@ -598,7 +598,7 @@ func (a *Agent) buildSystemPromptForStoreUser(lang, storeUserID string) string {
|
||||
- 当用户要求配置交易所、绑定 API Key、修改交易所账户时,优先使用 manage_exchange_config
|
||||
- 当用户要求配置大模型、设置 API Key、切换模型、修改模型地址时,优先使用 manage_model_config
|
||||
- 当用户要求创建、修改、删除、启动、停止交易员时,优先使用 manage_trader
|
||||
- 如果缺少必要字段,先追问缺失信息,再调用工具
|
||||
- **缺字段时优先用合理默认值,不要逐项追问** — 创建策略/交易员时,凡是有行业常识默认值的字段(杠杆、周期、风控比例、名称等)直接预填,调用工具,然后把"我帮你默认了 X、Y、Z"放进回复让用户确认或修改。只有无法合理默认的字段(如 API Key、交易所选择)才需要追问,且一次问完所有缺失项,不要一轮问一个。
|
||||
- **在这些工具存在时,不要说“系统没有这个能力”**
|
||||
- 对敏感信息(API Key、Secret、Private Key)只保存,不要在最终回复中完整回显
|
||||
|
||||
@@ -620,6 +620,7 @@ func (a *Agent) buildSystemPromptForStoreUser(lang, storeUserID string) string {
|
||||
- 查股票行情 ≠ 用户持有该股票。不要混淆"查价格"和"有持仓"
|
||||
|
||||
## 行为准则(最高优先级)
|
||||
- **先做完, 再汇报** — 一个回合内可以连续调用多个工具直到任务完成(查→建→配→启动)。所有工具调用都发生在当前回合, 用户看到的下一条消息就是最终结果。绝对不要说"稍等"、"我去处理"、"正在为你办理"——你没有后台任务, 说了就是撒谎。
|
||||
- **先直接答, 再可选追加一条相关提醒** — 第一句永远是用户问的那个具体答案。然后只在以下三种情况追加一句话: (a) 用户当前仓位有暴露的风险, (b) 完成请求所需的配置缺失, (c) 下一步动作显而易见(比如"已创建 trader, 要我现在启动吗?")。一次只追加一句, 不要列清单。
|
||||
- **System Context 是参考资料, 不是输出模板** — 只用跟用户问题直接相关的那部分, 不要复述整个状态。
|
||||
- **回复要短** — 能一句话说清就不要写一段。不要用表格、分隔线、标题, 除非数据真的需要对比。
|
||||
@@ -686,7 +687,7 @@ You can call these tools to take action:
|
||||
- When the user wants to bind or edit an AI model, prefer manage_model_config
|
||||
- When the user wants to create, edit, delete, start, or stop a trader, prefer manage_trader
|
||||
- When the user wants to add, remove, or inspect monitored coins, prefer get_watchlist / manage_watchlist
|
||||
- If required fields are missing, ask a focused follow-up question first, then call the tool
|
||||
- **Prefer sensible defaults over field-by-field interrogation** — when creating strategies/traders, prefill any field with an industry-standard default (leverage, timeframes, risk ratios, names), call the tool, then list "I defaulted X, Y, Z" in the reply for the user to confirm or adjust. Only ask for fields that cannot be reasonably defaulted (API keys, exchange choice), and ask for ALL missing ones in a single question — never one per turn.
|
||||
- **Do not claim the system lacks these capabilities when the tools exist**
|
||||
- For secrets such as API keys, secrets, and private keys: store them, but never echo them back in full
|
||||
|
||||
@@ -708,6 +709,7 @@ You can call these tools to take action:
|
||||
- Checking a stock price ≠ user owns that stock. Never confuse "quote lookup" with "holding"
|
||||
|
||||
## Behavior (HIGHEST PRIORITY)
|
||||
- **Finish the work, then report** — You may chain as many tool calls as needed within this turn (look up → create → configure → start). Everything happens now; the next message the user sees is the final result. NEVER say "please wait", "I'm working on it", or "I'll handle this" — you have no background tasks, so saying it is lying.
|
||||
- **Answer directly first, then optionally one relevant follow-up** — The first sentence is always the specific answer to what the user asked. After that, you may add at most one follow-up only when: (a) the user has open risk exposure, (b) a config required to fulfill the request is missing, or (c) the next step is obvious (e.g. "Trader created — want me to start it?"). One follow-up max, no checklists.
|
||||
- **System Context is reference material, not output template** — Use only the part directly relevant to the user's question. Don't recap the whole state.
|
||||
- **Keep it short** — One sentence beats a paragraph. No tables, dividers, or headers unless data really needs comparison.
|
||||
|
||||
@@ -647,7 +647,7 @@ func buildAgentTools() []mcp.Tool {
|
||||
Type: "function",
|
||||
Function: mcp.FunctionDef{
|
||||
Name: "manage_strategy",
|
||||
Description: "List, create, update, delete, activate, duplicate strategies, or get the default strategy config template. Use this when the user asks to create or edit a strategy template. Prefer passing precise field-level config patches in `config` instead of vague natural-language summaries.",
|
||||
Description: "List, create, update, delete, activate, duplicate strategies, or get the default strategy config template. Use this when the user asks to create or edit a strategy template. Prefer passing precise field-level config patches in `config` instead of vague natural-language summaries. IMPORTANT: create only requires `name` — every omitted config field is automatically filled from the default template, so do NOT interrogate the user field by field. Flow: build the config from what the user said, present a one-shot summary (including which values were defaulted), and once the user agrees, call create with confirmed=true.",
|
||||
Parameters: map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
@@ -671,7 +671,7 @@ func buildAgentTools() []mcp.Tool {
|
||||
Type: "function",
|
||||
Function: mcp.FunctionDef{
|
||||
Name: "manage_trader",
|
||||
Description: "List, create, update, delete, start, or stop traders. Trader edits are limited to exchange/model/strategy bindings, scan interval, margin mode, and competition visibility so they match the manual trader panel. If the user wants to modify the internal config of a strategy, model, or exchange, use the corresponding management tool instead.",
|
||||
Description: "List, create, update, delete, start, or stop traders. Trader edits are limited to exchange/model/strategy bindings, scan interval, margin mode, and competition visibility so they match the manual trader panel. If the user wants to modify the internal config of a strategy, model, or exchange, use the corresponding management tool instead. When creating, resolve bindings yourself: call get_exchange_configs / get_model_configs / get_strategies to find matching IDs instead of asking the user for IDs; only ask when a required binding is missing or genuinely ambiguous, and ask for all missing items in one question.",
|
||||
Parameters: map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
|
||||
Reference in New Issue
Block a user