Spaces:
Running
Running
Update agent/agent.py
#2
by DeepImagix - opened
- agent/agent.py +9 -1
agent/agent.py
CHANGED
|
@@ -277,7 +277,15 @@ async def stream_agent(
|
|
| 277 |
yield _make_sse("tool_start", step, f"Running {action}...", action, time.time() - step_start)
|
| 278 |
|
| 279 |
# FIX: Pass thought to preserve model reasoning in conversation history
|
| 280 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
|
| 282 |
display = result[:1800] + "..." if len(result) > 1800 else result
|
| 283 |
yield _make_sse("result", step, display, action, tool_elapsed)
|
|
|
|
| 277 |
yield _make_sse("tool_start", step, f"Running {action}...", action, time.time() - step_start)
|
| 278 |
|
| 279 |
# FIX: Pass thought to preserve model reasoning in conversation history
|
| 280 |
+
tool_start = time.time()
|
| 281 |
+
result = await _dispatch_tool(action, tool_input)
|
| 282 |
+
tool_elapsed = time.time() - tool_start
|
| 283 |
+
|
| 284 |
+
# FIX: Only add user message — NO assistant message with JSON
|
| 285 |
+
messages.append({
|
| 286 |
+
"role": "user",
|
| 287 |
+
"content": f"[Tool Result from {action}]\n{result}\n\nContinue with next JSON action or finish."
|
| 288 |
+
})
|
| 289 |
|
| 290 |
display = result[:1800] + "..." if len(result) > 1800 else result
|
| 291 |
yield _make_sse("result", step, display, action, tool_elapsed)
|