29 Commits

Author SHA1 Message Date
tinkle-community
b15c2da3a9 feat(strategy): English-only XYZ stock prompt + flat-account aggression + tier promote
The strategy prompt the LLM saw for a Chinese-language single-symbol US
stock trader was an incoherent zh/en patchwork — schema in Chinese,
role definition in English, hard constraints in English, custom prompt
back in Chinese — with crypto-flavored BTC/ETH vs Altcoin labelling that
made no sense for ARM-USDC. The LLM responded by being conservative and
boring. When it finally tried to open, the validator rejected the order
because the validator classified the stock as an altcoin (1x equity cap
= 112 USDT max) while the prompt said 5x cap (= 559 USDT).

- kernel/engine_prompt.go (BuildSystemPrompt): all eight prompt sections
  now respect e.GetLanguage() consistently. For single-symbol
  Hyperliquid XYZ assets (US stocks, commodities, forex) we additionally
  force the language to English regardless of the strategy's stored
  language — US-equity reasoning lands better in English and prevents
  the language-mix incoherence. The Hard Constraints section drops the
  BTC/ETH vs Altcoin two-tier split when the strategy trades a single
  instrument and shows one Position Value Limit line tagged with the
  actual symbol. The JSON example uses that symbol instead of the
  legacy BTCUSDT/ETHUSDT. The legacy stored custom_prompt (which was
  Chinese for stock quick-creates) is replaced for XYZ assets by
  buildXYZStockCustomPrompt — a built-in English long-only stock
  briefing that includes a Flat-Account Rule: when Current Positions
  is None, the agent MUST open a long this cycle (size 40-60% probing
  if technicals are mixed, 80-100% on a confirmed breakout). This is
  the "be in the market, not on the sidelines" stance the quick-trade
  flow needed; wait/hold are reserved for when a position already
  exists.

- kernel/engine_position.go + trader/auto_trader_risk.go + agent/trade.go:
  Hyperliquid XYZ assets now use the BTC/ETH higher tier rather than
  the altcoin tier in all three position-value enforcement points. A
  shared isMajorAsset / isMajorTradeSymbol helper treats BTC/ETH crypto
  perps AND any IsXyzDexAsset symbol as the higher tier. With 5x
  equity cap, the AI's confident-open decisions on US stocks now pass
  validation instead of erroring out with "altcoin single coin position
  value cannot exceed 112 USDT".

Net result: on a flat US-stock single-symbol trader, the agent opens
a sized position with stop-loss and take-profit on the very first
flat cycle, manages it (trail / partial / cut), and reports honestly
to the user. The "agent does nothing" complaint is closed.
2026-05-29 22:15:35 +08:00
tinkle-community
1851508353 feat(agent): make the assistant agentic - visible tools, LLM voice, full toolset
The agent felt like an artificial idiot because the LLM almost never spoke
for itself: 14+ Go paths injected fmt.Sprintf canned replies, the frontend
filtered out tool-progress events so users saw three dots for 10-20s, the
main prompt told the LLM "be a trading partner" AND "answer only what's
asked", and the planner sliced the toolset by inferred domain so a "BTC
dropped, how much am I losing?" question couldn't see positions and market
at the same time.

- agent/central_brain.go: shouldTrustDeterministicSkillReply now always
  returns false. Successful mutations (trader/strategy/model/exchange
  create/update/start/stop/delete) flow through reviewTaskCompletion so the
  LLM sees the real outcome JSON and writes the user-facing prose. The
  trade-confirmation regex path (handleTradeConfirmation) was already
  outside this code path and is unaffected.

- agent/agent.go: rewrite the Behavior section of the main system prompt.
  Replace the contradictory "answer only what's asked / don't upsell" with
  "lead with the direct answer, then optionally one relevant follow-up
  only when (a) open risk, (b) missing config, or (c) the next step is
  obvious — e.g. created, want me to start it?". Explicitly authorize
  chaining ("if the user says create and start, do both this turn") and
  ban "please wait / I'll get back to you" language because there is no
  background job to come back from.

- agent/tools.go: plannerToolsForText always returns the full 22-tool set
  (new __all__ domain). The old per-domain trimming hid manage_trader from
  market questions and execute_trade from anything that didn't look like
  an explicit trade — cross-domain reasoning was structurally blocked. The
  compact-vs-full strategy schema switch is preserved so mutation intents
  still see the full config schema.

- web/src/components/agent/{AgentStepPanel,ChatMessages}.tsx: stop
  filtering tool: steps. Map raw tool names to friendly labels with emoji
  ("get_positions" → "📊 检查持仓") in zh/en/id. Users now see what the
  agent is doing in real time instead of silence. central_brain routing
  chatter still gets dropped.

- agent/planner_tools_test.go: tests updated to assert the new
  full-toolset behavior and the compact-vs-full strategy schema switch.
2026-05-29 22:13:05 +08:00
tinklefund
f4ee723aa2 feat(agent): surface Hyperliquid stock trading context
- Add stock symbol panel and agent chat page wiring

- Update onboarding and tool visibility for focused trader flows

- Tighten related tests around configuration and trader scope
2026-05-25 01:25:10 +08:00
shinchan-zhai
ab5873e2de refactor(agent): improve legacy loop comment and extract domain variable
Clarify the rationale for not injecting conversation history in the
legacy loop comment, and extract plannerToolDomainForText result into
a named variable for readability.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-12 00:16:20 +08:00
shinchan-zhai
e2ccc6b911 fix(agent): eliminate cross-turn topic pollution in legacy loop
Remove conversation history injection from thinkAndActLegacyWithStore.
Previously, the legacy loop appended all prior Q&A turns, causing the
LLM to re-answer topics from earlier conversations (e.g. strategy data
leaking into a wallet balance question). Each legacy-loop call is now
treated as a standalone request with domain-filtered tools.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-11 23:51:18 +08:00
shinchan-zhai
bf289e8eb3 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>
2026-05-11 21:12:48 +08:00
shinchan-zhai
9f25bf49bf fix(agent): use provider registry for claw402, echo reasoning_content for thinking models, add Beta badge
- Agent now uses mcp.NewAIClientByProvider() for claw402 provider, ensuring
  x402 payment signing works correctly instead of generic HTTP client
- Added ReasoningContent field to Message/LLMResponse structs and wired
  serialization/parsing so DeepSeek thinking models work in multi-turn
- Added Beta badge to Agent nav tab in HeaderBar

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-11 20:22:32 +08:00
shinchan-zhai
ca8bed4a58 fix(agent): add TargetRef nil guards and ensureHistory for robustness
- Add nil checks for session.TargetRef in all four execute*Action
  handlers (Trader/Exchange/Model/Strategy) to prevent panic on
  corrupted sessions; bulk-delete and query actions are excluded
- Add ensureHistory() helper and call it in runPlannedAgentWithContextMode
  to prevent nil panic when history is not initialized

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-11 16:43:36 +08:00
shinchan-zhai
94844b7139 fix(agent): guard async maintenance goroutine and add timeout to diagnosis ctx
- Add stopCh check in runPostResponseMaintenanceAsync to respect agent
  shutdown, preventing goroutine leak on Agent.Stop()
- Replace bare context.Background() in handleTraderDiagnosisSkill with
  a 30s timeout context for proper deadline propagation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-11 16:37:30 +08:00
lky-spec
e67a927a4f Refine strategy creation flow and diagnostics 2026-05-09 14:48:24 +08:00
lky-spec
0f11be77f8 Improve NOFXi agent strategy creation flow 2026-05-06 17:00:05 +08:00
lky-spec
159f27dfdd Improve NOFXi agent product handling 2026-05-02 22:55:10 +08:00
lky-spec
25d0b30ea9 Split strategy config by strategy type 2026-04-28 20:19:24 +08:00
lky-spec
2d45e7ab15 Refine agent strategy routing and config handling 2026-04-28 19:37:44 +08:00
lky-spec
fc6c42ac11 Revert "Revert "Clean up reverted strategy prompt remnants""
This reverts commit 03a307939e.
2026-04-28 15:54:37 +08:00
lky-spec
5ff7212cb3 Revert "Revert "Trim agent planning tools and validate strategy patches""
This reverts commit 3619f82796.
2026-04-28 15:54:36 +08:00
lky-spec
3619f82796 Revert "Trim agent planning tools and validate strategy patches"
This reverts commit fe0dbce367.
2026-04-28 15:53:53 +08:00
lky-spec
03a307939e Revert "Clean up reverted strategy prompt remnants"
This reverts commit 8d8a0cc72b.
2026-04-28 15:53:53 +08:00
lky-spec
8d8a0cc72b Clean up reverted strategy prompt remnants 2026-04-28 15:50:45 +08:00
lky-spec
fe0dbce367 Trim agent planning tools and validate strategy patches 2026-04-28 15:45:47 +08:00
lky-spec
30a703a827 Unify agent routing and tighten exchange config 2026-04-28 11:58:58 +08:00
lky-spec
e8eafce1e0 Require explicit agent mutation targets 2026-04-26 22:38:16 +08:00
lky-spec
ce3a8582af Simplify agent skill routing and config updates 2026-04-26 22:22:12 +08:00
lky-spec
cfd91069d3 Centralize active skill field extraction 2026-04-26 20:44:09 +08:00
lky-spec
903eb591eb Improve active skill schema handling 2026-04-26 11:58:29 +08:00
lky-spec
9ee931ee30 v2 2026-04-25 20:24:46 +08:00
lky-spec
c244e4cdf1 change v1 2026-04-25 16:18:45 +08:00
lky-spec
737f9bca95 Enhance NOFXi agent workflow and diagnostics 2026-04-19 16:06:28 +08:00
lky-spec
5c4e7502d7 feat: integrate NOFXi agent into dev 2026-04-18 16:06:42 +08:00