Skip to content

Commit b01c7d2

Browse files
authored
Merge pull request #11 from cowagent/fix-max-turns-none-check
fix: Add max_turns None check and enhanced error logging
2 parents e40f4b5 + 36e2e38 commit b01c7d2

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

agentmesh/protocol/agent_stream.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ def run_stream(self, user_message: str) -> str:
8888

8989
final_response = ""
9090
turn = 0
91+
92+
# Safety check: ensure max_turns is valid
93+
if self.max_turns is None:
94+
logger.warning("max_turns is None, using default value 10")
95+
self.max_turns = 10
9196

9297
try:
9398
while turn < self.max_turns:
@@ -159,7 +164,9 @@ def run_stream(self, user_message: str) -> str:
159164
logger.warning(f"Reached max turns: {self.max_turns}")
160165

161166
except Exception as e:
167+
import traceback
162168
logger.error(f"Agent execution error: {e}")
169+
logger.error(f"Full traceback:\n{traceback.format_exc()}")
163170
self._emit_event("error", {"error": str(e)})
164171
raise
165172

0 commit comments

Comments
 (0)