fix(s04): use early-continue idiom in problem code block

The problem block used a nested `if block.type == "tool_use":` while the
solution block and code.py use `if block.type != "tool_use": continue`.
This made the problem->solution diff show two changes instead of the one
the section teaches (the README states only one place in the loop changed).
Align all three README variants (zh/en/ja) to the early-continue idiom.
This commit is contained in:
hardness1020
2026-05-28 10:34:42 -07:00
parent c586792bbb
commit 6d4970977d
3 changed files with 24 additions and 21 deletions

View File

@@ -21,13 +21,14 @@ def agent_loop(messages):
while True:
# ... LLM call ...
for block in response.content:
if block.type == "tool_use":
log_to_file(block) # 一行追加
check_permission(block) # 一行追加
notify_slack(block) # さらに一行追加
output = execute(block)
auto_git_add(block) # さらに一行追加
# ... もうループが見えない
if block.type != "tool_use":
continue
log_to_file(block) # 一行追加
check_permission(block) # 一行追加
notify_slack(block) # さらに一行追加
output = execute(block)
auto_git_add(block) # さらに一行追加
# ... もうループが見えない
```
拡張したいのは Agent の振る舞いなのに、変更しているのはループそのもの。ループは安定した核心であるべき。拡張は外側に掛ける。