Skip to content

Commit a510aef

Browse files
committed
fix: print full s11 continuation output
1 parent 06ac34e commit a510aef

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

s11_error_recovery/code.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,14 @@ def agent_loop(messages: list, context: dict):
352352
break
353353
if query.strip().lower() in ("q", "exit", ""):
354354
break
355+
turn_start = len(history)
355356
history.append({"role": "user", "content": query})
356357
agent_loop(history, context)
357358
context = update_context(context, history)
358-
for block in history[-1]["content"]:
359-
if getattr(block, "type", None) == "text":
360-
print(block.text)
359+
for msg in history[turn_start:]:
360+
if msg.get("role") != "assistant":
361+
continue
362+
for block in msg["content"]:
363+
if getattr(block, "type", None) == "text":
364+
print(block.text)
361365
print()

s20_comprehensive/code.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,14 +2004,13 @@ def agent_loop(messages: list, context: dict):
20042004
messages.append({"role": "user", "content": build_user_content(results)})
20052005

20062006

2007-
def print_last_assistant(messages: list):
2008-
for msg in reversed(messages):
2007+
def print_turn_assistants(messages: list, turn_start: int):
2008+
for msg in messages[turn_start:]:
20092009
if msg.get("role") != "assistant":
20102010
continue
20112011
for block in msg.get("content", []):
20122012
if getattr(block, "type", None) == "text":
20132013
terminal_print(block.text)
2014-
break
20152014

20162015

20172016
def cron_autorun_loop(history: list, context: dict):
@@ -2021,14 +2020,15 @@ def cron_autorun_loop(history: list, context: dict):
20212020
if not fired:
20222021
continue
20232022
with agent_lock:
2023+
turn_start = len(history)
20242024
for job in fired:
20252025
history.append({"role": "user",
20262026
"content": f"[Scheduled] {job.prompt}"})
20272027
terminal_print(
20282028
f" \033[35m[cron auto] {job.prompt[:60]}\033[0m")
20292029
agent_loop(history, context)
20302030
context.update(update_context(context, history))
2031-
print_last_assistant(history)
2031+
print_turn_assistants(history, turn_start)
20322032

20332033

20342034
if __name__ == "__main__":
@@ -2047,11 +2047,12 @@ def cron_autorun_loop(history: list, context: dict):
20472047
if query.strip().lower() in ("q", "exit", ""):
20482048
break
20492049
trigger_hooks("UserPromptSubmit", query)
2050+
turn_start = len(history)
20502051
history.append({"role": "user", "content": query})
20512052
with agent_lock:
20522053
agent_loop(history, context)
20532054
context = update_context(context, history)
2054-
print_last_assistant(history)
2055+
print_turn_assistants(history, turn_start)
20552056

20562057
inbox = consume_lead_inbox(route_protocol=True)
20572058
if inbox:

0 commit comments

Comments
 (0)