Add debug logging to diagnose empty task results
**Problem**: Task "create a gitea repo" completed 86 messages but returned generic fallback "Task completed (86 messages, $0.71)" with no actual work done. Zero tool calls tracked, zero assistant messages captured. **Debug additions**: 1. Log message type for first 5 messages and every 20th message to see what message types we're receiving from Agent SDK 2. Log ResultMessage contents: has_result, assistant_msgs count, tool_calls count to understand what was captured 3. Log tools used (if any) to verify tool tracking is working **Next**: Restart bot and retry failing task. Check logs to see: - What message types are actually being received (expecting AssistantMessage) - Whether tool_use blocks are present in content - Why tool_names list is empty despite work being done Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -588,6 +588,11 @@ class LLMInterface:
|
|||||||
message_count += 1
|
message_count += 1
|
||||||
self._last_message_count = message_count
|
self._last_message_count = message_count
|
||||||
|
|
||||||
|
# DEBUG: Log message type to understand what we're receiving
|
||||||
|
msg_type = type(message).__name__
|
||||||
|
if message_count <= 5 or message_count % 20 == 0:
|
||||||
|
logger.debug(f"[LLM] Message #{message_count}: {msg_type}")
|
||||||
|
|
||||||
if isinstance(message, AssistantMessage) and hasattr(message, 'content'):
|
if isinstance(message, AssistantMessage) and hasattr(message, 'content'):
|
||||||
if isinstance(message.content, str):
|
if isinstance(message.content, str):
|
||||||
assistant_messages.append(message.content)
|
assistant_messages.append(message.content)
|
||||||
@@ -601,6 +606,11 @@ class LLMInterface:
|
|||||||
self._last_tool_names = tool_names.copy()
|
self._last_tool_names = tool_names.copy()
|
||||||
|
|
||||||
if isinstance(message, ResultMessage):
|
if isinstance(message, ResultMessage):
|
||||||
|
# DEBUG: Log what we captured during message processing
|
||||||
|
logger.debug(f"[LLM] ResultMessage: has_result={bool(message.result)}, assistant_msgs={len(assistant_messages)}, tool_calls={len(tool_names)}")
|
||||||
|
if tool_names:
|
||||||
|
logger.debug(f"[LLM] Tools used: {', '.join(list(dict.fromkeys(tool_names))[:10])}")
|
||||||
|
|
||||||
result_text = message.result or "\n".join(assistant_messages)
|
result_text = message.result or "\n".join(assistant_messages)
|
||||||
|
|
||||||
if not result_text and tool_names:
|
if not result_text and tool_names:
|
||||||
|
|||||||
Reference in New Issue
Block a user