Skip to content

Commit 2db2332

Browse files
Fix coder agent exec (#50)
1 parent 102e6e0 commit 2db2332

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/magentic_ui/agents/_coder.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,10 +550,27 @@ async def monitor_pause() -> None:
550550
),
551551
inner_messages=inner_messages,
552552
)
553+
except Exception as e:
554+
logger.error(f"Error in CoderAgent: {e}")
555+
# add to chat history
556+
self._chat_history.append(
557+
TextMessage(
558+
content=f"An error occurred while executing the code: {e}",
559+
source=self.name,
560+
)
561+
)
562+
yield Response(
563+
chat_message=TextMessage(
564+
content="An error occurred while executing the code.",
565+
source=self.name,
566+
metadata={"internal": "no"},
567+
),
568+
inner_messages=inner_messages,
569+
)
553570
finally:
554571
# Cancel the monitor task.
555-
monitor_pause_task.cancel()
556572
try:
573+
monitor_pause_task.cancel()
557574
await monitor_pause_task
558575
except asyncio.CancelledError:
559576
pass

0 commit comments

Comments
 (0)