Skip to content

Commit b72cfa9

Browse files
committed
Added agent request timeout for longer models
1 parent f8159bf commit b72cfa9

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

codeplain_REST_api.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
MAX_RETRIES = 4
1313
RETRY_DELAY = 3
1414

15+
# Timeout for agent session requests (/agent/start, /agent/continue). A single agent
16+
# turn on the slow extended-thinking Bedrock models (Claude Sonnet 5, Opus 4.8) can run
17+
# up to the server's 590s request budget, so the client must outlast it — anything past
18+
# the server's 600s platform deadline is dead anyway.
19+
AGENT_REQUEST_TIMEOUT = 620
20+
1521
RETRY_ERROR_CODES = [
1622
"LLMInternalError",
1723
]
@@ -581,7 +587,7 @@ def agent_start(
581587
# Ask the server to run this session on the task's stronger escalation
582588
# model (the model choice itself stays server-side).
583589
payload["escalated"] = True
584-
return self.post_request(endpoint_url, headers, payload, run_state)
590+
return self.post_request(endpoint_url, headers, payload, run_state, timeout=AGENT_REQUEST_TIMEOUT)
585591

586592
def agent_continue(
587593
self, session_id: str, tool_results: list[dict], run_state: RunState, keep_session_alive: bool = False
@@ -593,7 +599,7 @@ def agent_continue(
593599
"tool_results": tool_results,
594600
"keep_session_alive": keep_session_alive,
595601
}
596-
return self.post_request(endpoint_url, headers, payload, run_state)
602+
return self.post_request(endpoint_url, headers, payload, run_state, timeout=AGENT_REQUEST_TIMEOUT)
597603

598604
def agent_continue_with_message(self, session_id: str, message: str, run_state: RunState):
599605
"""Continue an agent session by adding a new user message (without tool results)."""
@@ -605,7 +611,7 @@ def agent_continue_with_message(self, session_id: str, message: str, run_state:
605611
"user_message": message, # Additional context as user message
606612
"keep_session_alive": True, # Keep session alive for continuation
607613
}
608-
return self.post_request(endpoint_url, headers, payload, run_state)
614+
return self.post_request(endpoint_url, headers, payload, run_state, timeout=AGENT_REQUEST_TIMEOUT)
609615

610616
def agent_end_session(self, session_id: str, run_state: RunState):
611617
"""Explicitly end an agent session and remove it from the server."""

0 commit comments

Comments
 (0)