fix(orchestrator): cap MCP tool waits at 50 s below the client timeout
Claude Code's MCP client abandons a tool call before 240 s with "The operation timed out.", so review_wait, decision_wait and rule_request_wait now wait at most MCP_WAIT_CAP (50 s) and tell the caller to call again while the status is pending. HTTP waits keep WAIT_CAP (300 s). kvb-git-diff step 3 asks for timeout_seconds 50. 🎯 Fix: 95 % 💥 Break: 2 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 93 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b15dd5e414
commit
909ea85605
7 files changed
+17
-13
No files matched your search
@@ -9,6 +9,7 @@ from .errors import Conflict, Missing, ToolError
|
||||
from .fields import (
|
||||
COMMAND_LIMIT,
|
||||
DESCRIPTION_LIMIT,
|
||||
MCP_WAIT_CAP,
|
||||
OPTION_LIMIT,
|
||||
PATH_LIMIT,
|
||||
WAIT_CAP,
|
||||
@@ -233,7 +234,7 @@ class Asking:
|
||||
def decision_wait(self, arguments: dict) -> dict:
|
||||
expect(arguments, ("id", "timeout_seconds"))
|
||||
decision_id = field(arguments, "id")
|
||||
record = self.decisions.wait(decision_id, seconds(arguments, "timeout_seconds", WAIT_CAP))
|
||||
record = self.decisions.wait(decision_id, seconds(arguments, "timeout_seconds", MCP_WAIT_CAP))
|
||||
if record is None:
|
||||
raise ToolError(f"no decision {decision_id}")
|
||||
return decision_state(record)
|
||||
@@ -8,6 +8,8 @@ from .errors import ToolError
|
||||
from .signed import limits, signing
|
||||
|
||||
WAIT_CAP = 300
|
||||
# Claude Code's MCP client abandons a tool call before 240 s ("The operation timed out."); 50 s proved safe 2026-11-27.
|
||||
MCP_WAIT_CAP = 50
|
||||
TEXT_LIMIT = 20_000
|
||||
COMMAND_LIMIT = 4000
|
||||
PATH_LIMIT = limits.PATH_LIMIT
|
||||
|
||||
@@ -6,7 +6,7 @@ from http import HTTPStatus
|
||||
from . import NAME
|
||||
from .choosing import CHOICE_REQUEST
|
||||
from .errors import RpcError, ToolError
|
||||
from .fields import OPTION_LIMIT, WAIT_CAP
|
||||
from .fields import MCP_WAIT_CAP, OPTION_LIMIT
|
||||
from .requesting import AGENT_CAP
|
||||
from .reviewing import GATES
|
||||
from .rules import RULE_KINDS
|
||||
@@ -30,7 +30,7 @@ def rpc_error(request_id: object, code: int, message: str) -> dict:
|
||||
class Mcp:
|
||||
def tools(self) -> list[dict]:
|
||||
review_id = text_property("Review id that review_request returned.")
|
||||
wait = {"type": "number", "minimum": 0, "description": f"Seconds to wait, capped at {WAIT_CAP}."}
|
||||
wait = {"type": "number", "minimum": 0, "description": f"Seconds to wait, capped at {MCP_WAIT_CAP}; on status pending call again."}
|
||||
option = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -63,7 +63,7 @@ class Mcp:
|
||||
tool(
|
||||
"review_wait",
|
||||
f"Wait until the operator decides a review or the timeout passes, then return its status. "
|
||||
f"Waits at most {WAIT_CAP} seconds.",
|
||||
f"Waits at most {MCP_WAIT_CAP} seconds.",
|
||||
{"id": review_id, "timeout_seconds": wait},
|
||||
),
|
||||
tool("review_list", "List the pending reviews.", {}),
|
||||
@@ -84,7 +84,7 @@ class Mcp:
|
||||
"Wait until the operator picks an option or the timeout passes, then return the status "
|
||||
"(pending, decided), the chosen label or the operator's own one-line Other answer and, for a click, message and answer: the id and text of the operator's "
|
||||
"passkey-signed answer, a radio call to the asking agent; check it with operator_message(message, answer, your name) "
|
||||
f"before acting on the choice. Waits at most {WAIT_CAP} seconds.",
|
||||
f"before acting on the choice. Waits at most {MCP_WAIT_CAP} seconds.",
|
||||
{"id": text_property("Decision id that decision_request returned."), "timeout_seconds": wait},
|
||||
),
|
||||
tool(
|
||||
@@ -106,7 +106,7 @@ class Mcp:
|
||||
tool(
|
||||
"rule_request_wait",
|
||||
f"Wait until the operator accepts or denies a rule request or the timeout passes, then return its status "
|
||||
f"(pending, accepted, denied), the stored rule id and the operator's reason. Waits at most {WAIT_CAP} seconds.",
|
||||
f"(pending, accepted, denied), the stored rule id and the operator's reason. Waits at most {MCP_WAIT_CAP} seconds.",
|
||||
{"id": text_property("Request id that rule_request returned."), "timeout_seconds": wait},
|
||||
),
|
||||
tool(
|
||||
|
||||
@@ -4,7 +4,7 @@ import time
|
||||
|
||||
from .denying import request_status, request_words, requester_of
|
||||
from .errors import Conflict, Missing, ToolError
|
||||
from .fields import WAIT_CAP, bounded, decode, expect, field, seconds
|
||||
from .fields import MCP_WAIT_CAP, bounded, decode, expect, field, seconds
|
||||
from .records import iso_epoch
|
||||
from .rules import EVERY_AGENT, rule_fields, rule_matches, signed_fields, subject_of
|
||||
from .signed import signing
|
||||
@@ -97,7 +97,7 @@ class Requesting:
|
||||
def rule_request_wait(self, arguments: dict) -> dict:
|
||||
expect(arguments, ("id", "timeout_seconds"))
|
||||
request_id = field(arguments, "id")
|
||||
record = self.rule_requests.wait(request_id, seconds(arguments, "timeout_seconds", WAIT_CAP))
|
||||
record = self.rule_requests.wait(request_id, seconds(arguments, "timeout_seconds", MCP_WAIT_CAP))
|
||||
if record is None:
|
||||
raise ToolError(f"no rule request {request_id}")
|
||||
return request_state(record, time.time())
|
||||
|
||||
@@ -16,7 +16,7 @@ from .diffs import (
|
||||
valid_sealed,
|
||||
)
|
||||
from .errors import Conflict, Missing, ToolError
|
||||
from .fields import WAIT_CAP, bounded, decode, expect, field, seconds
|
||||
from .fields import MCP_WAIT_CAP, bounded, decode, expect, field, seconds
|
||||
from .review_page import review_files
|
||||
from .signed import limits, review_signed
|
||||
|
||||
@@ -127,7 +127,7 @@ class Reviewing:
|
||||
def wait(self, arguments: dict) -> dict:
|
||||
expect(arguments, ("id", "timeout_seconds"))
|
||||
review_id = field(arguments, "id")
|
||||
timeout = seconds(arguments, "timeout_seconds", WAIT_CAP)
|
||||
timeout = seconds(arguments, "timeout_seconds", MCP_WAIT_CAP)
|
||||
return proven(found(self.reviews.wait(review_id, timeout), review_id))
|
||||
|
||||
def pending(self, arguments: dict) -> dict:
|
||||
|
||||
Reference in new issue
Block a user