max_run_secs 默认值由 3600(60 分钟)改为 0(不限制),避免长任务被单次执行时间上限中断;需要时可在 config.json 的 agents 段显式配置。同步版本号提升至 0.4.3 并更新 CHANGELOG。
58 lines
2.6 KiB
Rust
58 lines
2.6 KiB
Rust
use crate::config::LLMProviderConfig;
|
||
use crate::providers::ProviderRuntimeConfig;
|
||
|
||
#[derive(Debug, Clone)]
|
||
pub struct AgentRuntimeConfig {
|
||
pub provider: ProviderRuntimeConfig,
|
||
pub context_window_tokens: usize,
|
||
pub context_summary_char_budget: usize,
|
||
pub max_tool_iterations: usize,
|
||
pub tool_result_max_chars: usize,
|
||
pub context_tool_result_trim_chars: usize,
|
||
/// 图片上下文限制配置
|
||
pub max_images_in_context: usize,
|
||
pub max_image_age_rounds: usize,
|
||
/// LLM 请求瞬态失败的最大重试次数(仅对 timeout/502/503/504/429 等可恢复错误重试)。
|
||
/// 0 表示不重试。归属 agent 行为层,不进 ProviderRuntimeConfig(保持 provider 构造包纯净)。
|
||
pub max_retries: u32,
|
||
/// 单次 process() 的墙钟预算(秒)。超时后 agent 优雅退出并给出说明。
|
||
/// 防止 max_tool_iterations 很大(默认 1000)时,单轮合法长跑占住
|
||
/// topic serial lock 数小时,期间所有新用户消息无限排队。
|
||
/// 0 表示不限制。默认见 DEFAULT_MAX_RUN_SECS。
|
||
pub max_run_secs: u64,
|
||
}
|
||
|
||
/// 单次 agent run 默认墙钟预算。默认 0 表示不限制,需要时可在 config.json 的 agents 段按 agent 设置。
|
||
pub const DEFAULT_MAX_RUN_SECS: u64 = 0;
|
||
|
||
impl From<LLMProviderConfig> for AgentRuntimeConfig {
|
||
fn from(config: LLMProviderConfig) -> Self {
|
||
let context_window_tokens = config.context_window_tokens();
|
||
let context_summary_char_budget = config.context_summary_char_budget();
|
||
|
||
Self {
|
||
provider: ProviderRuntimeConfig {
|
||
provider_type: config.provider_type,
|
||
name: config.name,
|
||
base_url: config.base_url,
|
||
api_key: config.api_key,
|
||
extra_headers: config.extra_headers,
|
||
llm_timeout_secs: config.llm_timeout_secs,
|
||
model_id: config.model_id,
|
||
temperature: config.temperature,
|
||
max_tokens: config.max_tokens,
|
||
model_extra: config.model_extra,
|
||
},
|
||
context_window_tokens,
|
||
context_summary_char_budget,
|
||
max_tool_iterations: config.max_tool_iterations,
|
||
tool_result_max_chars: config.tool_result_max_chars,
|
||
context_tool_result_trim_chars: config.context_tool_result_trim_chars,
|
||
max_images_in_context: config.max_images_in_context,
|
||
max_image_age_rounds: config.max_image_age_rounds,
|
||
max_retries: config.max_retries,
|
||
max_run_secs: config.max_run_secs,
|
||
}
|
||
}
|
||
}
|