appendToolDebugLog 把每次工具解析的输入文本和解析结果写入日志文件, 用于排查模型为什么没产生 tool_call。出错不影响主流程。
(path string, attempt int, text string, calls []officialtypes.ToolCall)
| 2416 | // appendToolDebugLog 把每次工具解析的输入文本和解析结果写入日志文件, |
| 2417 | // 用于排查模型为什么没产生 tool_call。出错不影响主流程。 |
| 2418 | func appendToolDebugLog(path string, attempt int, text string, calls []officialtypes.ToolCall) { |
| 2419 | f, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644) |
| 2420 | if err != nil { |
| 2421 | return |
| 2422 | } |
| 2423 | defer f.Close() |
| 2424 | callsJSON, _ := json.Marshal(calls) |
| 2425 | fmt.Fprintf(f, "\n=== attempt %d ===\ntext: %s\ncalls: %s\n", attempt, text, string(callsJSON)) |
| 2426 | } |