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/// Maximum allowed timeout (1 hour)
6/// Any user-specified timeout above this is capped
7pub const MAX_TIMEOUT_SECS: u64 = 3600;
8
9/// Minimum timeout (10 seconds)
10/// Prevents unreasonably short timeouts that would cause failures
11pub const MIN_TIMEOUT_SECS: u64 = 10;
12
13/// Resolve timeout with deterministic bounds (never returns 0 or unbounded)
14/// This pattern ensures execution always has a bounded duration.
15///
16/// # Arguments
17/// * `user_timeout` - Optional user-specified timeout in seconds
18///
19/// # Returns
20/// A bounded timeout value that is:
21/// - DEFAULT_TIMEOUT_SECS if None or 0
22/// - MAX_TIMEOUT_SECS if exceeds maximum
23/// - The user value if within bounds
24#[inline]
25pub const fn resolve_timeout(user_timeout: Option<u64>) -> u64 {
26 match user_timeout {
27 None => DEFAULT_TIMEOUT_SECS,
28 Some(0) => DEFAULT_TIMEOUT_SECS,
29 Some(t) if t > MAX_TIMEOUT_SECS => MAX_TIMEOUT_SECS,
30 Some(t) if t < MIN_TIMEOUT_SECS => MIN_TIMEOUT_SECS,
31 Some(t) => t,
32 }
33}