Skip to content

Commit cd726b1

Browse files
Haytwpfleger96
andcommitted
fix(dev-mcp): align outer budget timeouts with 20-minute shell cap
buzz-dev-mcp raised MAX_TIMEOUT_MS to 1_200_000 (20 min). The two outer layers that bound every MCP tool call were not updated in the same pass: - buzz-agent's BUZZ_AGENT_TOOL_TIMEOUT_SECS default (660s) would kill the MCP server at 11 min, before a 20-min shell call could complete. - buzz-acp's DEFAULT_IDLE_TIMEOUT_SECS (900s) was documented as "600s max shell + 300s breathing room" — that arithmetic was stale. Fix: - buzz-agent: raise BUZZ_AGENT_TOOL_TIMEOUT_SECS default to 1_260s (20-min cap + 60s cleanup headroom); update README.md accordingly. - buzz-acp: raise DEFAULT_IDLE_TIMEOUT_SECS to 1_500s and rewrite its doc comment (1200s max shell + 300s breathing room). - Tests: pin the new defaults and add a cross-crate budget-ordering const assertion (shell cap <= agent timeout < ACP idle < max turn). Co-authored-by: Will Pfleger <[email protected]> Signed-off-by: Will Pfleger <[email protected]>
1 parent b8a1fe7 commit cd726b1

3 files changed

Lines changed: 67 additions & 8 deletions

File tree

‎crates/buzz-acp/src/config.rs‎

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ use crate::filter::SubscriptionRule;
2020
///
2121
/// Sized for slow turns where the agent may go silent on its outer ACP channel
2222
/// while running long sub-tools (e.g. a buzz-agent running another agent, or
23-
/// codex/claude doing multi-minute single tool calls). 900s gives 300s of
24-
/// breathing room above the 600s max shell timeout, so legitimate long-running
23+
/// codex/claude doing multi-minute single tool calls). 1500s gives 300s of
24+
/// breathing room above the 1200s max shell timeout, so legitimate long-running
2525
/// tool calls don't race the idle deadline.
2626
/// Override via `--idle-timeout` / `BUZZ_ACP_IDLE_TIMEOUT`.
27-
pub(crate) const DEFAULT_IDLE_TIMEOUT_SECS: u64 = 900;
27+
pub(crate) const DEFAULT_IDLE_TIMEOUT_SECS: u64 = 1_500;
2828

2929
/// Default absolute wall-clock cap per agent turn (2 hours).
3030
/// Override via `--max-turn-duration` / `BUZZ_ACP_MAX_TURN_DURATION`.
@@ -2757,9 +2757,9 @@ channels = "ALL"
27572757
// ── Idle timeout constant + guard (PR #935) ───────────────────────────────
27582758

27592759
#[test]
2760-
fn default_idle_timeout_is_900_seconds() {
2760+
fn default_idle_timeout_is_1500_seconds() {
27612761
// Lock the constant value so accidental changes are caught.
2762-
assert_eq!(DEFAULT_IDLE_TIMEOUT_SECS, 900);
2762+
assert_eq!(DEFAULT_IDLE_TIMEOUT_SECS, 1_500);
27632763
}
27642764

27652765
#[test]
@@ -2779,6 +2779,45 @@ channels = "ALL"
27792779
}
27802780
}
27812781

2782+
#[test]
2783+
fn budget_ordering_invariant_shell_cap_plus_headroom_fits_within_idle_timeout() {
2784+
// Asserts the three-layer budget relationship introduced in PR #7185:
2785+
// buzz-dev-mcp MAX_TIMEOUT_MS (1 200 000 ms = 1 200s)
2786+
// ≤ buzz-agent BUZZ_AGENT_TOOL_TIMEOUT_SECS default (1 260s)
2787+
// < buzz-acp DEFAULT_IDLE_TIMEOUT_SECS (1 500s)
2788+
//
2789+
// The idle deadline must strictly outlast the agent tool timeout so a
2790+
// legitimately long-running tool call is killed by buzz-agent first (at
2791+
// 1 260s) rather than the ACP idle watchdog. The 240s gap gives the agent
2792+
// time to handle the timeout, emit a response, and reset the idle clock
2793+
// before the ACP connection dies.
2794+
//
2795+
// If any of these constants change the compiler catches the inversion here.
2796+
// Cross-crate constants are mirrored as literals; grep for PR #7185 to
2797+
// find the authoritative source if you need to update them.
2798+
const SHELL_CAP_MS: u64 = 1_200_000; // buzz-dev-mcp MAX_TIMEOUT_MS
2799+
const SHELL_CAP_SECS: u64 = SHELL_CAP_MS / 1_000;
2800+
const AGENT_TOOL_TIMEOUT_SECS: u64 = 1_260; // buzz-agent BUZZ_AGENT_TOOL_TIMEOUT_SECS default
2801+
2802+
const {
2803+
// Shell cap must not exceed the agent's per-tool-call timeout.
2804+
assert!(
2805+
SHELL_CAP_SECS <= AGENT_TOOL_TIMEOUT_SECS,
2806+
"shell cap must be <= agent tool timeout"
2807+
);
2808+
// Agent tool timeout must be strictly less than the ACP idle deadline.
2809+
assert!(
2810+
AGENT_TOOL_TIMEOUT_SECS < DEFAULT_IDLE_TIMEOUT_SECS,
2811+
"agent tool timeout must be < ACP idle timeout"
2812+
);
2813+
// ACP idle timeout must remain below the max turn duration.
2814+
assert!(
2815+
DEFAULT_IDLE_TIMEOUT_SECS < DEFAULT_MAX_TURN_DURATION_SECS,
2816+
"ACP idle timeout must be < max turn duration"
2817+
);
2818+
}
2819+
}
2820+
27822821
// --- BUZZ_ACP_ALLOWED_RESPOND_TO gate ---
27832822

27842823
fn parse_allowed_respond_to(raw: &[&str]) -> Result<HashSet<RespondTo>, ConfigError> {

‎crates/buzz-agent/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Everything is environment variables. No flags, no config files. (We are a subpro
159159
| `BUZZ_AGENT_MAX_CONTEXT_TOKENS` | `200000` | Provider context window used by the handoff gate. |
160160
| `BUZZ_AGENT_MAX_HANDOFFS` | `10` | Max context handoffs per session before falling back to truncation. |
161161
| `BUZZ_AGENT_LLM_TIMEOUT_SECS` | `240` | Max seconds with no response bytes before abandoning an LLM call (per-read inactivity, not wall-clock). |
162-
| `BUZZ_AGENT_TOOL_TIMEOUT_SECS` | `660` | Per-tool call timeout in seconds |
162+
| `BUZZ_AGENT_TOOL_TIMEOUT_SECS` | `1260` | Per-tool call timeout in seconds |
163163
| `BUZZ_AGENT_MAX_PARALLEL_TOOLS` | `8` | Max concurrent tool calls per turn (1 = sequential) |
164164
| `BUZZ_AGENT_MAX_SESSIONS` | unlimited | Max concurrent ACP sessions. Sessions are cheap; default has no cap. |
165165
| `BUZZ_AGENT_MAX_LINE_BYTES` | `4194304` | 4 MiB. Hard cap on inbound JSON-RPC frames. |
@@ -326,7 +326,7 @@ The trust boundary is **the operator who launched the agent**. The harness, MCP
326326
| Tool calls per turn | 64 | `MAX_TOOL_CALLS_PER_TURN` |
327327
| Loop rounds | 0 (unlimited) | `BUZZ_AGENT_MAX_ROUNDS` |
328328
| LLM read inactivity timeout | 240 s | `BUZZ_AGENT_LLM_TIMEOUT_SECS` |
329-
| Tool call timeout | 660 s | `BUZZ_AGENT_TOOL_TIMEOUT_SECS` |
329+
| Tool call timeout | 1260 s | `BUZZ_AGENT_TOOL_TIMEOUT_SECS` |
330330

331331
## What This Is NOT
332332

‎crates/buzz-agent/src/config.rs‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ impl Config {
709709
max_output_tokens: parse_env("BUZZ_AGENT_MAX_OUTPUT_TOKENS", 65_536)?,
710710
max_token_recoveries: parse_env("BUZZ_AGENT_MAX_TOKEN_RECOVERIES", 3u32)?,
711711
llm_timeout: Duration::from_secs(parse_env("BUZZ_AGENT_LLM_TIMEOUT_SECS", 240)?),
712-
tool_timeout: Duration::from_secs(parse_env("BUZZ_AGENT_TOOL_TIMEOUT_SECS", 660)?),
712+
tool_timeout: Duration::from_secs(parse_env("BUZZ_AGENT_TOOL_TIMEOUT_SECS", 1_260)?),
713713
mcp_init_timeout: Duration::from_secs(parse_env(
714714
"BUZZ_AGENT_MCP_INIT_TIMEOUT_SECS",
715715
30,
@@ -2462,4 +2462,24 @@ mod tests {
24622462
assert_eq!(pricing_authority("https://api.databricks.com/v1"), None);
24632463
assert_eq!(pricing_authority("https://custom.llm.corp/v1"), None);
24642464
}
2465+
2466+
#[test]
2467+
fn default_tool_timeout_is_1260_seconds() {
2468+
// Lock the production default so accidental regressions are caught.
2469+
// This value must remain >= buzz-dev-mcp's MAX_TIMEOUT_MS (1_200s) to
2470+
// give every shell(timeout_ms=1_200_000) call time to complete before
2471+
// buzz-agent kills the MCP server. See PR #7185 for the full budget chain.
2472+
//
2473+
// 1_260s is the literal default passed to parse_env in Config::from_env().
2474+
// Update here if and only if you update that literal; the test name makes
2475+
// "grep for old value" reliable.
2476+
const DEFAULT_TOOL_TIMEOUT_SECS: u64 = 1_260;
2477+
const {
2478+
// Shell cap (1_200_000 ms = 1_200s) must fit inside the agent timeout.
2479+
assert!(
2480+
1_200u64 <= DEFAULT_TOOL_TIMEOUT_SECS,
2481+
"agent tool timeout must be >= dev-mcp shell cap (1200s)"
2482+
);
2483+
}
2484+
}
24652485
}

0 commit comments

Comments
 (0)