From 2ba5b7e837ec266b58f9a582206fbbae89ef30eb Mon Sep 17 00:00:00 2001
From: neystan <2918360904@qq.com>
Date: Sat, 23 May 2026 13:47:22 +0800
Subject: [PATCH] fix: prevent tool_result order corruption in s07 reminder
injection
---
s07_skill_loading/code.py | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/s07_skill_loading/code.py b/s07_skill_loading/code.py
index 66159a3..80bffa5 100644
--- a/s07_skill_loading/code.py
+++ b/s07_skill_loading/code.py
@@ -344,13 +344,10 @@ def agent_loop(messages: list):
global rounds_since_todo
while True:
if rounds_since_todo >= 3 and messages:
- last = messages[-1]
- if last["role"] == "user" and isinstance(last.get("content"), list):
- last["content"].insert(0, {
- "type": "text",
- "text": "Update your todos.",
- })
-
+ messages.append({"role": "user",
+ "content": "Update your todos."})
+ rounds_since_todo = 0
+
response = client.messages.create(
model=MODEL, system=SYSTEM, messages=messages,
tools=TOOLS, max_tokens=8000,