fix(agent): reduce verbose responses — focus answers on user's question only

Root cause: when planner fails (402 payment), legacy loop dumps all system
context to LLM which outputs everything. Also final response prompt was too
weak — LLM treated all observations as required output.

Changes:
- Strengthen system prompt: "answer ONLY what user asked", no tables/tutorials
  unless requested, no self-intro repeats, no "next step" suggestions
- Add compact observation summary for final response (step summaries only,
  no raw JSON blobs)
- Domain-filtered tool selection in legacy loop to prevent over-fetching
- Fix domain routing: "钱包/wallet" → account domain (not model), with
  exchange configs included for wallet context
- Widen wallet fast-path: no longer requires "claw402" keyword
- Anti-repetition instructions in planner step selector

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shinchan-zhai
2026-05-11 21:12:48 +08:00
parent 9f25bf49bf
commit bf289e8eb3
4 changed files with 93 additions and 38 deletions

View File

@@ -70,7 +70,7 @@ func plannerToolDomainForText(text string) string {
if hasExplicitManagementDomainCue(text, "trader") || containsAny(lower, []string{"交易员", "trader", "启动", "停止交易员", "扫描间隔", "竞技场"}) {
return "trader"
}
if containsAny(lower, []string{"余额", "资产", "仓位", "持仓", "订单", "成交", "交易历史", "balance", "position", "positions", "trade history", "account"}) {
if containsAny(lower, []string{"余额", "资产", "仓位", "持仓", "订单", "成交", "交易历史", "balance", "position", "positions", "trade history", "account", "钱包", "wallet"}) {
return "account"
}
if containsAny(lower, []string{"行情", "价格", "k线", "kline", "market", "price", "btc", "eth", "sol", "usdt", "股票", "stock"}) {
@@ -84,7 +84,7 @@ func plannerToolNamesForDomain(domain string) []string {
case "market":
return []string{"get_market_snapshot", "get_market_price", "get_kline", "search_stock"}
case "account":
return []string{"get_balance", "get_positions", "get_trade_history"}
return []string{"get_balance", "get_positions", "get_trade_history", "get_exchange_configs"}
case "trader":
return []string{"get_model_configs", "get_exchange_configs", "get_strategies", "manage_trader"}
case "model":