diff --git a/s04_hooks/README.zh.md b/s04_hooks/README.zh.md index 3aa21e2c..12acbfb2 100644 --- a/s04_hooks/README.zh.md +++ b/s04_hooks/README.zh.md @@ -85,7 +85,7 @@ def trigger_hooks(event: str, *args): def context_inject_hook(query: str) -> str | None: """Inject current working directory info into every prompt.""" print(f"\033[90m[HOOK] UserPromptSubmit: working in {WORKDIR}\033[0m") - return None # return None = no modification, let prompt through + return None # return None = 不修改提示词,直接放行 register_hook("UserPromptSubmit", context_inject_hook) ``` @@ -139,7 +139,7 @@ def summary_hook(messages: list) -> str | None: for b in (m.get("content") if isinstance(m.get("content"), list) else []) if isinstance(b, dict) and b.get("type") == "tool_result") print(f"\033[90m[HOOK] Stop: session used {tool_count} tool calls\033[0m") - return None # return None = allow stop, return string = force continuation + return None # return None = 允许终止, return string = 强制继续 register_hook("Stop", summary_hook) ``` @@ -153,7 +153,7 @@ tool_calls = [ if not tool_calls: force = trigger_hooks("Stop", messages) # ← 退出之前 if force: - # hook returned a message → inject it and continue + # hook 返回消息 → 注入消息并继续执行 messages.append({"role": "user", "content": force}) continue return diff --git a/s05_todo_write/README.zh.md b/s05_todo_write/README.zh.md index a7fafbef..99cf71b9 100644 --- a/s05_todo_write/README.zh.md +++ b/s05_todo_write/README.zh.md @@ -40,14 +40,14 @@ class TodoManager: self.items = [] def update(self, todos: list | str) -> str: - # Parse and validate before replacing the current list. + # 替换当前列表前进行解析与校验 validated = [] ... self.items = validated return self.render() def render(self) -> str: - # [ ] pending, [>] in progress, [x] completed + # [ ] 待办, [>] 进行中, [x] 已完成 ... diff --git a/s06_subagent/README.zh.md b/s06_subagent/README.zh.md index fa39eb09..9f933437 100644 --- a/s06_subagent/README.zh.md +++ b/s06_subagent/README.zh.md @@ -31,7 +31,7 @@ Agent 在修一个 bug。为了追踪调用链,它读取了许多文件;每 **run_subagent** 创建新的消息列表,运行嵌套循环,并返回最终文本: ```python -SUB_TOOLS = list(BASE_TOOLS) # no task tool +SUB_TOOLS = list(BASE_TOOLS) # 不含 task 工具 def run_subagent(prompt: str) -> str: messages = [{"role": "user", "content": prompt}]