From c9f9f4318e390e2a99d07c2dfcb2e10e0e73eec3 Mon Sep 17 00:00:00 2001 From: Yinghao Fan Date: Fri, 31 Oct 2025 02:06:20 +0800 Subject: [PATCH] fix: Correct error handling in decision parsing Changes: - Updated error handling in `GetFullDecision` and `parseFullDecisionResponse` functions to return the decision object even when an error occurs, improving the clarity of error messages. This ensures that the decision object is consistently returned, allowing for better debugging and handling of errors in the decision-making process. --- decision/engine.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/decision/engine.go b/decision/engine.go index 76bcffca..97181572 100644 --- a/decision/engine.go +++ b/decision/engine.go @@ -109,7 +109,7 @@ func GetFullDecision(ctx *Context, mcpClient *mcp.Client) (*FullDecision, error) // 4. 解析AI响应 decision, err := parseFullDecisionResponse(aiResponse, ctx.Account.TotalEquity, ctx.BTCETHLeverage, ctx.AltcoinLeverage) if err != nil { - return nil, fmt.Errorf("解析AI响应失败: %w", err) + return decision, fmt.Errorf("解析AI响应失败: %w", err) } decision.Timestamp = time.Now() @@ -427,7 +427,7 @@ func parseFullDecisionResponse(aiResponse string, accountEquity float64, btcEthL return &FullDecision{ CoTTrace: cotTrace, Decisions: []Decision{}, - }, fmt.Errorf("提取决策失败: %w\n\n=== AI思维链分析 ===\n%s", err, cotTrace) + }, fmt.Errorf("提取决策失败: %w", err) } // 3. 验证决策 @@ -435,7 +435,7 @@ func parseFullDecisionResponse(aiResponse string, accountEquity float64, btcEthL return &FullDecision{ CoTTrace: cotTrace, Decisions: decisions, - }, fmt.Errorf("决策验证失败: %w\n\n=== AI思维链分析 ===\n%s", err, cotTrace) + }, fmt.Errorf("决策验证失败: %w", err) } return &FullDecision{