vtcode_config/constants/execution.rs
1/// Default timeout for agent loop execution (10 minutes)
2/// Used when no timeout is specified or when 0 is passed
3pub const DEFAULT_TIMEOUT_SECS: u64 = 600;
4
5/// Base throttle delay (ms) for the agent runner loop between repeated identical tool calls.
6pub const LOOP_THROTTLE_BASE_MS: u64 = 75;
7/// Base throttle delay (ms) for repeated calls inside the tool registry execution facade.
8pub const LOOP_THROTTLE_REGISTRY_BASE_MS: u64 = 25;
9/// Maximum throttle delay (ms) ceiling applied to both the runner loop and the registry facade.
10pub const LOOP_THROTTLE_MAX_MS: u64 = 500;
11
12/// Default tool execution ceiling in seconds (matches TimeoutsConfig::default_ceiling_seconds).
13pub const DEFAULT_TOOL_TIMEOUT_SECS: u64 = 180;
14/// Maximum wait in seconds when a tool is rate-limited before surfacing an error.
15pub const MAX_RATE_LIMIT_WAIT_SECS: u64 = 5;
16/// Default OAuth / auth-flow timeout in seconds.
17pub const DEFAULT_AUTH_FLOW_TIMEOUT_SECS: u64 = 300;
18
19/// Maximum number of consecutive idle turns before the agent runner aborts.
20pub const IDLE_TURN_LIMIT: usize = 3;
21
22/// Maximum recent error records kept per agent session for recovery diagnostics.
23pub const DEFAULT_MAX_RECENT_ERRORS: usize = 10;
24
25/// Maximum number of simultaneously open tool circuit breakers before the agent pauses.
26pub const DEFAULT_MAX_OPEN_CIRCUITS: usize = 3;
27
28/// Maximum allowed timeout (1 hour)
29/// Any user-specified timeout above this is capped
30pub const MAX_TIMEOUT_SECS: u64 = 3600;
31
32/// Minimum timeout (10 seconds)
33/// Prevents unreasonably short timeouts that would cause failures
34pub const MIN_TIMEOUT_SECS: u64 = 10;
35
36/// Resolve timeout with deterministic bounds (never returns 0 or unbounded)
37/// This pattern ensures execution always has a bounded duration.
38///
39/// # Arguments
40/// * `user_timeout` - Optional user-specified timeout in seconds
41///
42/// # Returns
43/// A bounded timeout value that is:
44/// - DEFAULT_TIMEOUT_SECS if None or 0
45/// - MAX_TIMEOUT_SECS if exceeds maximum
46/// - The user value if within bounds
47#[inline]
48pub const fn resolve_timeout(user_timeout: Option<u64>) -> u64 {
49 match user_timeout {
50 None => DEFAULT_TIMEOUT_SECS,
51 Some(0) => DEFAULT_TIMEOUT_SECS,
52 Some(t) if t > MAX_TIMEOUT_SECS => MAX_TIMEOUT_SECS,
53 Some(t) if t < MIN_TIMEOUT_SECS => MIN_TIMEOUT_SECS,
54 Some(t) => t,
55 }
56}