类 ExecutionConfig
This class replaces the previous TimeoutConfig and RetryConfig classes, providing a single unified configuration for controlling execution behavior of both model API calls and tool executions.
Use the builder pattern to construct instances. All fields are optional and nullable.
Standard Defaults
MODEL_DEFAULTS: 5 minutes timeout, 3 retry attempts with exponential backoffTOOL_DEFAULTS: 5 minutes timeout, no retry (1 attempt only)
Configuration Merging
Use mergeConfigs(ExecutionConfig, ExecutionConfig) to combine configurations with
parameter-by-parameter precedence. This allows layering configs from different sources:
// Priority: per-request > agent-level > component-defaults > system-defaults
ExecutionConfig effective = ExecutionConfig.mergeConfigs(
perRequestConfig,
ExecutionConfig.mergeConfigs(agentConfig, ExecutionConfig.MODEL_DEFAULTS)
);
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明static final ExecutionConfigStandard defaults for model API calls.Predicate that determines if an error should be retried.static final ExecutionConfigStandard defaults for tool executions. -
方法概要
修饰符和类型方法说明static ExecutionConfig.Builderbuilder()Creates a new builder for ExecutionConfig.Gets the backoff multiplier.Gets the initial backoff duration.Gets the maximum number of attempts.Gets the maximum backoff duration.Gets the retry predicate.Gets the timeout duration.static ExecutionConfigmergeConfigs(ExecutionConfig primary, ExecutionConfig fallback) Merges two ExecutionConfig instances, with primary config taking precedence.
-
字段详细资料
-
RETRYABLE_ERRORS
Predicate that determines if an error should be retried.Retryable errors include:
- HTTP 429 (Rate Limiting)
- HTTP 5xx (Server errors)
- Timeout errors
- Network/IO errors
Non-retryable errors include:
- HTTP 400 (Bad Request) - parameter validation failures
- HTTP 401/403 (Authentication/Authorization errors)
- Other 4xx client errors
-
MODEL_DEFAULTS
Standard defaults for model API calls.- Timeout: 5 minutes
- Max attempts: 3 (initial + 2 retries)
- Initial backoff: 2 seconds
- Max backoff: 30 seconds
- Backoff multiplier: 2.0 (exponential)
- Retry on: retryable errors only (429, 5xx, timeout, network errors)
Note: The backoff times are set higher (2s initial, 30s max) to better handle rate limiting (HTTP 429) from model providers during high-concurrency scenarios.
-
TOOL_DEFAULTS
Standard defaults for tool executions.- Timeout: 5 minutes
- Max attempts: 1 (no retry)
-
-
方法详细资料
-
getTimeout
Gets the timeout duration.- 返回:
- the timeout duration, or null if not set
-
getMaxAttempts
Gets the maximum number of attempts.- 返回:
- the max attempts (including initial attempt), or null if not set
-
getInitialBackoff
Gets the initial backoff duration.- 返回:
- the initial backoff duration, or null if not set
-
getMaxBackoff
Gets the maximum backoff duration.- 返回:
- the max backoff duration, or null if not set
-
getBackoffMultiplier
Gets the backoff multiplier.- 返回:
- the backoff multiplier, or null if not set
-
getRetryOn
Gets the retry predicate.- 返回:
- the predicate to determine if an error should be retried, or null if not set
-
builder
Creates a new builder for ExecutionConfig.- 返回:
- a new Builder instance
-
mergeConfigs
Merges two ExecutionConfig instances, with primary config taking precedence.This method performs parameter-by-parameter merging: for each parameter, if the primary value is non-null, it is used; otherwise, the fallback value is used. This allows proper layering of configs from different sources.
Merge Behavior:
- Each field: primary != null ? primary : fallback
- If primary is null, returns fallback directly
- If fallback is null, returns primary directly
Example:
ExecutionConfig defaults = ExecutionConfig.MODEL_DEFAULTS; ExecutionConfig agentLevel = ExecutionConfig.builder() .timeout(Duration.ofMinutes(2)) .build(); // Result: timeout=2min, maxAttempts=3 (from defaults), ... ExecutionConfig merged = ExecutionConfig.mergeConfigs(agentLevel, defaults);- 参数:
primary- the primary config (higher priority)fallback- the fallback config (lower priority)- 返回:
- merged config, or null if both are null
-