Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions backend/app/services/agent_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2802,13 +2802,23 @@ async def _send_message_to_agent(from_agent_id: uuid.UUID, args: dict) -> str:
timeout=120.0,
)
try:
import asyncio
import httpx
for _round in range(max_tool_rounds):
response = await llm_client.complete(
messages=full_msgs,
tools=tools_for_llm if tools_for_llm else None,
temperature=0.7,
max_tokens=4096,
)
# Retry up to 3 times on transient LLM timeouts before aborting
for _attempt in range(3):
try:
response = await llm_client.complete(
messages=full_msgs,
tools=tools_for_llm if tools_for_llm else None,
temperature=0.7,
max_tokens=4096,
)
break
except httpx.ReadTimeout:
if _attempt == 2:
raise
await asyncio.sleep(2 ** _attempt) # 1s, then 2s

# Track tokens from API response
real_tokens = extract_usage_tokens(response.usage)
Expand Down Expand Up @@ -2920,7 +2930,8 @@ async def _send_message_to_agent(from_agent_id: uuid.UUID, args: dict) -> str:
except Exception as e:
import traceback
traceback.print_exc()
return f"❌ Message send error: {str(e)[:200]}"
err_detail = str(e) or type(e).__name__
return f"❌ Message send error: {err_detail[:200]}"



Expand Down