mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-01 17:17:24 -04:00
fix: capture tool messages in conversation history for summarizer
**Root Cause:** The summarizer was not receiving tool execution results (buy/sell trades) because they were never captured to conversation_history. **What was captured:** - User: 'Please analyze positions' - Assistant: 'I will buy/sell...' - Assistant: 'Done <FINISH_SIGNAL>' **What was MISSING:** - Tool: buy 14 NVDA at $185.24 - Tool: sell 1 GOOGL at $245.15 **Changes:** - Added tool message capture in trading loop (line 649) - Extract tool_name and tool_content from each tool message - Capture to conversation_history before processing - Changed message['tool_name'] to message['name'] for consistency **Impact:** Now the summarizer sees the actual tool results, not just the AI's intentions. Combined with alpha.8's prompt improvements, summaries will accurately reflect executed trades. Fixes reasoning summaries that contradicted actual trades.
This commit is contained in:
@@ -419,7 +419,7 @@ class BaseAgent:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if tool_name:
|
if tool_name:
|
||||||
message["tool_name"] = tool_name
|
message["name"] = tool_name # Use "name" not "tool_name" for consistency with summarizer
|
||||||
if tool_input:
|
if tool_input:
|
||||||
message["tool_input"] = tool_input
|
message["tool_input"] = tool_input
|
||||||
|
|
||||||
@@ -643,6 +643,11 @@ Summary:"""
|
|||||||
tool_msgs = extract_tool_messages(response)
|
tool_msgs = extract_tool_messages(response)
|
||||||
for tool_msg in tool_msgs:
|
for tool_msg in tool_msgs:
|
||||||
tool_name = getattr(tool_msg, 'name', None) or tool_msg.get('name') if isinstance(tool_msg, dict) else None
|
tool_name = getattr(tool_msg, 'name', None) or tool_msg.get('name') if isinstance(tool_msg, dict) else None
|
||||||
|
tool_content = getattr(tool_msg, 'content', '') or tool_msg.get('content', '') if isinstance(tool_msg, dict) else str(tool_msg)
|
||||||
|
|
||||||
|
# Capture tool message to conversation history
|
||||||
|
self._capture_message("tool", tool_content, tool_name=tool_name)
|
||||||
|
|
||||||
if tool_name in ['buy', 'sell']:
|
if tool_name in ['buy', 'sell']:
|
||||||
action_count += 1
|
action_count += 1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user