This commit is contained in:
@@ -28,10 +28,21 @@ import httpx
|
||||
from cloud.internal_api.models import PlannerDecisionError, PlannerDecisionResponse
|
||||
from host_agent.config import HostAgentConfig
|
||||
from host_agent.planner_context import current_planner_execution_context
|
||||
from runtime.tool_calling_client import ToolCallDecision, ToolCallUnavailable, ToolCallUsage
|
||||
from runtime.tool_calling_client import (
|
||||
ToolCallDecision,
|
||||
ToolCallUnavailable,
|
||||
ToolCallUsage,
|
||||
)
|
||||
from runtime.tool_specs import ToolSpec
|
||||
|
||||
|
||||
_CLOUD_PROVIDER_MAX_TIMEOUT_SECONDS = 120.0
|
||||
_CLOUD_PROXY_TRANSPORT_GRACE_SECONDS = 5.0
|
||||
_CLOUD_PROXY_HTTP_TIMEOUT_SECONDS = (
|
||||
_CLOUD_PROVIDER_MAX_TIMEOUT_SECONDS + _CLOUD_PROXY_TRANSPORT_GRACE_SECONDS
|
||||
)
|
||||
|
||||
|
||||
class CloudProxyToolCallingClient:
|
||||
def __init__(
|
||||
self,
|
||||
@@ -69,7 +80,9 @@ class CloudProxyToolCallingClient:
|
||||
}
|
||||
for spec in tools
|
||||
],
|
||||
"timeout_seconds": timeout,
|
||||
# Legacy Cloud API versions use this field. Current Cloud API versions
|
||||
# resolve the provider timeout from the active Provider profile.
|
||||
"timeout_seconds": min(timeout, _CLOUD_PROVIDER_MAX_TIMEOUT_SECONDS),
|
||||
}
|
||||
context = current_planner_execution_context()
|
||||
if context is not None:
|
||||
@@ -85,7 +98,7 @@ class CloudProxyToolCallingClient:
|
||||
f"/internal/v1/hosts/{self.config.host_id}/planner/decide",
|
||||
json=payload,
|
||||
headers={"Authorization": f"Bearer {self.config.token}"},
|
||||
timeout=timeout + 5,
|
||||
timeout=_CLOUD_PROXY_HTTP_TIMEOUT_SECONDS,
|
||||
)
|
||||
except httpx.HTTPError as exc:
|
||||
raise ToolCallUnavailable(str(exc)) from exc
|
||||
|
||||
Reference in New Issue
Block a user