Fix s_full.py consistency: auto_compact keeps newest messages, nag reminder appends after tool_results

Two issues found during post-merge audit:
1. auto_compact used [:80000] (oldest) instead of [-80000:] (newest), inconsistent with s06
2. nag reminder used insert(0,...) instead of append(), inconsistent with s03
This commit is contained in:
CrazyBoyM
2026-03-30 00:09:37 +08:00
parent def7c9a03e
commit 16b927c8ee

View File

@@ -246,7 +246,7 @@ def auto_compact(messages: list) -> list:
with open(path, "w") as f: with open(path, "w") as f:
for msg in messages: for msg in messages:
f.write(json.dumps(msg, default=str) + "\n") f.write(json.dumps(msg, default=str) + "\n")
conv_text = json.dumps(messages, default=str)[:80000] conv_text = json.dumps(messages, default=str)[-80000:]
resp = client.messages.create( resp = client.messages.create(
model=MODEL, model=MODEL,
messages=[{"role": "user", "content": f"Summarize for continuity:\n{conv_text}"}], messages=[{"role": "user", "content": f"Summarize for continuity:\n{conv_text}"}],
@@ -697,7 +697,7 @@ def agent_loop(messages: list):
# s03: nag reminder (only when todo workflow is active) # s03: nag reminder (only when todo workflow is active)
rounds_without_todo = 0 if used_todo else rounds_without_todo + 1 rounds_without_todo = 0 if used_todo else rounds_without_todo + 1
if TODO.has_open_items() and rounds_without_todo >= 3: if TODO.has_open_items() and rounds_without_todo >= 3:
results.insert(0, {"type": "text", "text": "<reminder>Update your todos.</reminder>"}) results.append({"type": "text", "text": "<reminder>Update your todos.</reminder>"})
messages.append({"role": "user", "content": results}) messages.append({"role": "user", "content": results})
# s06: manual compress # s06: manual compress
if manual_compress: if manual_compress: