fix: 添加 System Prompt 修复 TodoWriteTool JSON 反序列化错误
问题:
- LLM 返回数组格式 [{...}] 导致反序列化失败
- TodoWriteTool 期望对象格式 {todos: [{...}]}
解决方案:
- 添加 defaultSystem 指导 LLM 使用正确的 JSON 格式
- 明确说明正确和错误的格式示例
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9d64bd2fff
commit
b00ec76638
1 file changed
+19
@@ -92,6 +92,25 @@ public class Application {
|
|||||||
applicationEventPublisher.publishEvent(new TodoUpdateEvent(this, event.todos())))
|
applicationEventPublisher.publishEvent(new TodoUpdateEvent(this, event.todos())))
|
||||||
.build())
|
.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
|
// Built-in tools
|
||||||
.defaultTools(
|
.defaultTools(
|
||||||
//Bash execution tool
|
//Bash execution tool
|
||||||
|
|||||||
Reference in new issue
Block a user