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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import asyncio
import json
from typing import Dict

Expand Down Expand Up @@ -48,10 +49,12 @@ def __init__(
*,
default_slippage_bps: int = 25,
quantity_precision: float = 1e-9,
max_llm_wait_time_sec: float = 600.0,
) -> None:
self._request = request
self._default_slippage_bps = default_slippage_bps
self._quantity_precision = quantity_precision
self._max_llm_wait_time_sec = max_llm_wait_time_sec
cfg = self._request.llm_model_config
self._model = model_utils.create_model_with_provider(
provider=cfg.provider,
Expand Down Expand Up @@ -200,7 +203,9 @@ async def _call_llm(self, prompt: str) -> TradePlanProposal:
agent's `response.content` is returned (or validated) as a
`LlmPlanProposal`.
"""
response = await self.agent.arun(prompt)
response = await asyncio.wait_for(
self.agent.arun(prompt), timeout=self._max_llm_wait_time_sec
)
# Agent may return a raw object or a wrapper with `.content`.
content = getattr(response, "content", None) or response
logger.debug("Received LLM response {}", content)
Expand Down