ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
"""
|
||||
TodoWrite tool - Task list management
|
||||
"""
|
||||
|
||||
from typing import Dict, Any
|
||||
from .base import BaseTool
|
||||
|
||||
|
||||
class TodoWriteTool(BaseTool):
|
||||
"""Creates and manages structured task lists"""
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "TodoWrite"
|
||||
|
||||
def _execute_impl(self, params: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""
|
||||
Update TODO list
|
||||
|
||||
- Use this tool to create and manage a structured task list
|
||||
- Track progress, organize complex tasks
|
||||
- Helps user understand progress
|
||||
"""
|
||||
# JSON null for required todos: same as empty list (LLM omit-as-null).
|
||||
todos = params["todos"]
|
||||
if todos is None:
|
||||
todos = []
|
||||
|
||||
# Validate todo format
|
||||
for todo in todos:
|
||||
if not isinstance(todo, dict) or not all(k in todo for k in ["id", "content", "status"]):
|
||||
return {"error": "Each todo must be a dict and must have id, content, and status"}
|
||||
if todo["status"] not in ["pending", "in_progress", "completed"]:
|
||||
return {"error": f"Invalid status: {todo['status']}"}
|
||||
|
||||
# Update state
|
||||
self.state.todos = todos
|
||||
|
||||
return {
|
||||
"total_todos": len(todos),
|
||||
"pending": sum(1 for t in todos if t["status"] == "pending"),
|
||||
"in_progress": sum(1 for t in todos if t["status"] == "in_progress"),
|
||||
"completed": sum(1 for t in todos if t["status"] == "completed")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user