From b00ec766385178b95f90d594d467f7e64d1731b4 Mon Sep 17 00:00:00 2001 From: hugh <1012760428@qq.com> Date: Fri, 30 Jan 2026 18:05:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=20System=20Prompt=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20TodoWriteTool=20JSON=20=E5=8F=8D=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: - LLM 返回数组格式 [{...}] 导致反序列化失败 - TodoWriteTool 期望对象格式 {todos: [{...}]} 解决方案: - 添加 defaultSystem 指导 LLM 使用正确的 JSON 格式 - 明确说明正确和错误的格式示例 Co-Authored-By: Claude Sonnet 4.5 --- .../springaicommunity/skills/Application.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/org/springaicommunity/skills/Application.java b/src/main/java/org/springaicommunity/skills/Application.java index d2ceea9..44a4db0 100644 --- a/src/main/java/org/springaicommunity/skills/Application.java +++ b/src/main/java/org/springaicommunity/skills/Application.java @@ -92,6 +92,25 @@ public class Application { applicationEventPublisher.publishEvent(new TodoUpdateEvent(this, event.todos()))) .build()) + // 添加 System Prompt 指导 TodoWrite 工具的正确使用 + .defaultSystem(""" + When using the TodoWrite tool, you MUST provide the todos parameter as an object with a "todos" array, not a direct array. + + Correct format: + { + "todos": [ + {"content": "task 1", "status": "pending"}, + {"content": "task 2", "status": "pending"} + ] + } + + Incorrect format (DO NOT USE): + [ + {"content": "task 1", "status": "pending"}, + {"content": "task 2", "status": "pending"} + ] + """) + // Built-in tools .defaultTools( //Bash execution tool