fix(tools): halve the wait_for_message ceiling to 300s

A mutual wait between two agents resolves only when both hit their cap,
so the ceiling is the worst-case idle burn. Name the constants instead of
repeating the literal, and align the interactive auto-resume timeout.
This commit is contained in:
Ahmed Allam
2026-08-02 02:15:51 +03:00
committed by Ahmed Allam
parent 6eec34df24
commit 49057f267f
2 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -540,7 +540,7 @@ async def _exhausted_recovery(
return result
_WAITING_AUTO_RESUME_TIMEOUT_S = 600.0
_WAITING_AUTO_RESUME_TIMEOUT_S = 300.0
async def _plain_waiting_timeout(
+11 -3
View File
@@ -218,11 +218,18 @@ def _session_items_payload(items: list[Any]) -> list[dict[str, Any]]:
return payload
@function_tool(timeout=601)
_WAIT_DEFAULT_TIMEOUT_S = 300
# Enforced by the SDK around the whole tool call, so it caps an oversized
# ``timeout_seconds`` the model asks for. One second of headroom lets the
# tool's own timeout fire first and return a clean result.
_WAIT_HARD_CEILING_S = _WAIT_DEFAULT_TIMEOUT_S + 1
@function_tool(timeout=_WAIT_HARD_CEILING_S)
async def wait_for_message( # noqa: PLR0911
ctx: RunContextWrapper,
reason: str = "Waiting for messages from other agents",
timeout_seconds: int = 600,
timeout_seconds: int = _WAIT_DEFAULT_TIMEOUT_S,
) -> str:
"""Pause this agent until a message lands in its inbox (or timeout).
@@ -255,7 +262,8 @@ async def wait_for_message( # noqa: PLR0911
reason: One-line note shown in graph snapshots while you're
waiting (helps a human or sibling agent debug who's stuck
on what).
timeout_seconds: Max seconds to wait (default 600). This is only
timeout_seconds: Max seconds to wait (default 300, and values above
that are cut short by a hard ceiling). This is only
a cap — the tool returns the INSTANT a message arrives, so a
larger value never makes you wait longer when the reply does
come. Right-size it to what you're waiting on: a short wait