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(crate) 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(crate) const MAX_TIMEOUT_SECS: u64 = 3600;
31
32/// Minimum timeout (10 seconds)
33/// Prevents unreasonably short timeouts that would cause failures
34pub(crate) const MIN_TIMEOUT_SECS: u64 = 10;
35
36/// Default maximum retry attempts for orchestrator operations.
37pub const DEFAULT_ORCHESTRATOR_MAX_RETRIES: u32 = 5;
38/// Default initial delay between orchestrator retries (milliseconds).
39pub const DEFAULT_ORCHESTRATOR_RETRY_INITIAL_DELAY_MS: u64 = 1_000;
40/// Default maximum delay between orchestrator retries (seconds).
41pub const DEFAULT_ORCHESTRATOR_RETRY_MAX_DELAY_SECS: u64 = 60;
42/// Default backoff multiplier for orchestrator retries.
43pub const DEFAULT_ORCHESTRATOR_RETRY_MULTIPLIER: f64 = 2.0;
44
45/// Resolve timeout with deterministic bounds (never returns 0 or unbounded)
46/// This pattern ensures execution always has a bounded duration.
47///
48/// # Arguments
49/// * `user_timeout` - Optional user-specified timeout in seconds
50///
51/// # Returns
52/// A bounded timeout value that is:
53/// - DEFAULT_TIMEOUT_SECS if None or 0
54/// - MAX_TIMEOUT_SECS if exceeds maximum
55/// - The user value if within bounds
56#[inline]
57pub const fn resolve_timeout(user_timeout: Option<u64>) -> u64 {
58 match user_timeout {
59 None => DEFAULT_TIMEOUT_SECS,
60 Some(0) => DEFAULT_TIMEOUT_SECS,
61 Some(t) if t > MAX_TIMEOUT_SECS => MAX_TIMEOUT_SECS,
62 Some(t) if t < MIN_TIMEOUT_SECS => MIN_TIMEOUT_SECS,
63 Some(t) => t,
64 }
65}