mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
feat: update tool output format, use plain string instead of json string (#881)
This commit is contained in:
@@ -340,11 +340,30 @@ class TodoWriteToolInvocation extends BaseToolInvocation<
|
||||
todos: finalTodos,
|
||||
};
|
||||
|
||||
// Create plain string format with system reminder
|
||||
const todosJson = JSON.stringify(finalTodos);
|
||||
let llmContent: string;
|
||||
|
||||
if (finalTodos.length === 0) {
|
||||
// Special message for empty todos
|
||||
llmContent = `Todo list has been cleared.
|
||||
|
||||
<system-reminder>
|
||||
Your todo list is now empty. DO NOT mention this explicitly to the user. You have no pending tasks in your todo list.
|
||||
</system-reminder>`;
|
||||
} else {
|
||||
// Normal message for todos with items
|
||||
llmContent = `Todos have been modified successfully. Ensure that you continue to use the todo list to track your progress. Please proceed with the current tasks if applicable
|
||||
|
||||
<system-reminder>
|
||||
Your todo list has changed. DO NOT mention this explicitly to the user. Here are the latest contents of your todo list:
|
||||
|
||||
${todosJson}. Continue on with the tasks at hand if applicable.
|
||||
</system-reminder>`;
|
||||
}
|
||||
|
||||
return {
|
||||
llmContent: JSON.stringify({
|
||||
success: true,
|
||||
todos: finalTodos,
|
||||
}),
|
||||
llmContent,
|
||||
returnDisplay: todoResultDisplay,
|
||||
};
|
||||
} catch (error) {
|
||||
@@ -353,11 +372,16 @@ class TodoWriteToolInvocation extends BaseToolInvocation<
|
||||
console.error(
|
||||
`[TodoWriteTool] Error executing todo_write: ${errorMessage}`,
|
||||
);
|
||||
|
||||
// Create plain string format for error with system reminder
|
||||
const errorLlmContent = `Failed to modify todos. An error occurred during the operation.
|
||||
|
||||
<system-reminder>
|
||||
Todo list modification failed with error: ${errorMessage}. You may need to retry or handle this error appropriately.
|
||||
</system-reminder>`;
|
||||
|
||||
return {
|
||||
llmContent: JSON.stringify({
|
||||
success: false,
|
||||
error: `Failed to write todos. Detail: ${errorMessage}`,
|
||||
}),
|
||||
llmContent: errorLlmContent,
|
||||
returnDisplay: `Error writing todos: ${errorMessage}`,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user