Skip to content

Commit aaa93bc

Browse files
authored
fix(agents): print final assistant response in s02-s12 (#39)
1 parent dbffe7c commit aaa93bc

11 files changed

Lines changed: 55 additions & 0 deletions

agents/s02_tool_use.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,9 @@ def agent_loop(messages: list):
140140
break
141141
history.append({"role": "user", "content": query})
142142
agent_loop(history)
143+
response_content = history[-1]["content"]
144+
if isinstance(response_content, list):
145+
for block in response_content:
146+
if hasattr(block, "text"):
147+
print(block.text)
143148
print()

agents/s03_todo_write.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,9 @@ def agent_loop(messages: list):
201201
break
202202
history.append({"role": "user", "content": query})
203203
agent_loop(history)
204+
response_content = history[-1]["content"]
205+
if isinstance(response_content, list):
206+
for block in response_content:
207+
if hasattr(block, "text"):
208+
print(block.text)
204209
print()

agents/s04_subagent.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,9 @@ def agent_loop(messages: list):
175175
break
176176
history.append({"role": "user", "content": query})
177177
agent_loop(history)
178+
response_content = history[-1]["content"]
179+
if isinstance(response_content, list):
180+
for block in response_content:
181+
if hasattr(block, "text"):
182+
print(block.text)
178183
print()

agents/s05_skill_loading.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,9 @@ def agent_loop(messages: list):
217217
break
218218
history.append({"role": "user", "content": query})
219219
agent_loop(history)
220+
response_content = history[-1]["content"]
221+
if isinstance(response_content, list):
222+
for block in response_content:
223+
if hasattr(block, "text"):
224+
print(block.text)
220225
print()

agents/s06_context_compact.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,9 @@ def agent_loop(messages: list):
239239
break
240240
history.append({"role": "user", "content": query})
241241
agent_loop(history)
242+
response_content = history[-1]["content"]
243+
if isinstance(response_content, list):
244+
for block in response_content:
245+
if hasattr(block, "text"):
246+
print(block.text)
242247
print()

agents/s07_task_system.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,9 @@ def agent_loop(messages: list):
239239
break
240240
history.append({"role": "user", "content": query})
241241
agent_loop(history)
242+
response_content = history[-1]["content"]
243+
if isinstance(response_content, list):
244+
for block in response_content:
245+
if hasattr(block, "text"):
246+
print(block.text)
242247
print()

agents/s08_background_tasks.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,9 @@ def agent_loop(messages: list):
225225
break
226226
history.append({"role": "user", "content": query})
227227
agent_loop(history)
228+
response_content = history[-1]["content"]
229+
if isinstance(response_content, list):
230+
for block in response_content:
231+
if hasattr(block, "text"):
232+
print(block.text)
228233
print()

agents/s09_agent_teams.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,9 @@ def agent_loop(messages: list):
397397
continue
398398
history.append({"role": "user", "content": query})
399399
agent_loop(history)
400+
response_content = history[-1]["content"]
401+
if isinstance(response_content, list):
402+
for block in response_content:
403+
if hasattr(block, "text"):
404+
print(block.text)
400405
print()

agents/s10_team_protocols.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,4 +478,9 @@ def agent_loop(messages: list):
478478
continue
479479
history.append({"role": "user", "content": query})
480480
agent_loop(history)
481+
response_content = history[-1]["content"]
482+
if isinstance(response_content, list):
483+
for block in response_content:
484+
if hasattr(block, "text"):
485+
print(block.text)
481486
print()

agents/s11_autonomous_agents.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,4 +570,9 @@ def agent_loop(messages: list):
570570
continue
571571
history.append({"role": "user", "content": query})
572572
agent_loop(history)
573+
response_content = history[-1]["content"]
574+
if isinstance(response_content, list):
575+
for block in response_content:
576+
if hasattr(block, "text"):
577+
print(block.text)
573578
print()

0 commit comments

Comments
 (0)