Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/agents/ideagen/material_organizer_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ def __init__(
language: str = "en",
api_key: str | None = None,
base_url: str | None = None,
api_version: str | None = None,
model: str | None = None,
):
super().__init__(
module_name="ideagen",
agent_name="material_organizer",
api_key=api_key,
base_url=base_url,
api_version=api_version,
model=model,
language=language,
)
Expand Down
3 changes: 3 additions & 0 deletions src/api/routers/ideagen.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,9 @@ async def websocket_ideagen(websocket: WebSocket):
task_manager.update_task_status(task_id, "error", error=str(e))

try:
# Send explicit error message for consistency and better frontend handling
await websocket.send_json({"type": "error", "content": str(e)})

await send_status(
websocket,
IdeaGenStage.ERROR,
Expand Down
8 changes: 4 additions & 4 deletions src/services/llm/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
logger = get_logger("LLMFactory")

# Default retry configuration
DEFAULT_MAX_RETRIES = 3
DEFAULT_RETRY_DELAY = 1.0 # seconds
DEFAULT_MAX_RETRIES = 5 # Increased for complex agents like Research
DEFAULT_RETRY_DELAY = 2.0 # seconds
DEFAULT_EXPONENTIAL_BACKOFF = True


Expand Down Expand Up @@ -197,8 +197,8 @@ def _is_retriable_llm_api_error(exc: BaseException) -> bool:
| tenacity.retry_if_exception_type(LLMTimeoutError)
| tenacity.retry_if_exception(_is_retriable_llm_api_error)
),
wait=tenacity.wait_exponential(multiplier=retry_delay, min=retry_delay, max=60),
stop=tenacity.stop_after_attempt(max_retries + 1),
wait=tenacity.wait_exponential(multiplier=retry_delay, min=retry_delay, max=120),
stop=tenacity.stop_after_attempt(max_retries + 2),
before_sleep=lambda retry_state: logger.warning(
f"LLM call failed (attempt {retry_state.attempt_number}/{max_retries + 1}), "
f"retrying in {retry_state.upcoming_sleep:.1f}s... Error: {str(retry_state.outcome.exception())}"
Expand Down