feat: support setting the tool_timeout in the main config file instead of only via an environment variable
This commit is contained in:
8 files changed
+125
-23
No files matched your search
@@ -70,6 +70,7 @@ pub struct AppConfig {
|
||||
pub summary_context_prompt: Option<String>,
|
||||
pub max_tool_result_chars: Option<usize>,
|
||||
pub max_concurrent_jobs: Option<usize>,
|
||||
pub tool_timeout: Option<u64>,
|
||||
|
||||
pub memory: Option<bool>,
|
||||
pub memory_cap_with_tools: Option<usize>,
|
||||
@@ -159,6 +160,7 @@ impl Default for AppConfig {
|
||||
summary_context_prompt: None,
|
||||
max_tool_result_chars: None,
|
||||
max_concurrent_jobs: None,
|
||||
tool_timeout: None,
|
||||
|
||||
memory: None,
|
||||
memory_cap_with_tools: None,
|
||||
@@ -249,6 +251,7 @@ impl AppConfig {
|
||||
summary_context_prompt: config.summary_context_prompt,
|
||||
max_tool_result_chars: config.max_tool_result_chars,
|
||||
max_concurrent_jobs: config.max_concurrent_jobs,
|
||||
tool_timeout: config.tool_timeout,
|
||||
|
||||
memory: config.memory,
|
||||
memory_cap_with_tools: config.memory_cap_with_tools,
|
||||
@@ -587,6 +590,9 @@ impl AppConfig {
|
||||
if let Some(v) = super::read_env_value::<usize>(&get_env_name("max_concurrent_jobs")) {
|
||||
self.max_concurrent_jobs = v;
|
||||
}
|
||||
if let Some(v) = super::read_env_value::<u64>(&get_env_name("tool_timeout")) {
|
||||
self.tool_timeout = v;
|
||||
}
|
||||
if let Some(v) = super::read_env_value::<String>(&get_env_name("summarization_prompt")) {
|
||||
self.summarization_prompt = v;
|
||||
}
|
||||
@@ -926,6 +932,49 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_config_copies_tool_timeout() {
|
||||
let cfg = Config {
|
||||
model_id: "test-model".to_string(),
|
||||
tool_timeout: Some(600),
|
||||
clients: vec![ClientConfig::default()],
|
||||
..Config::default()
|
||||
};
|
||||
|
||||
let app = AppConfig::from_config(cfg).unwrap();
|
||||
|
||||
assert_eq!(app.tool_timeout, Some(600));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial_test::serial]
|
||||
fn load_envs_overrides_tool_timeout() {
|
||||
let env_name = get_env_name("tool_timeout");
|
||||
let prev = env::var_os(&env_name);
|
||||
|
||||
let mut app = AppConfig::default();
|
||||
|
||||
unsafe { env::set_var(&env_name, "90") };
|
||||
app.load_envs();
|
||||
assert_eq!(app.tool_timeout, Some(90));
|
||||
|
||||
unsafe { env::set_var(&env_name, "0") };
|
||||
app.load_envs();
|
||||
assert_eq!(app.tool_timeout, Some(0));
|
||||
|
||||
unsafe { env::remove_var(&env_name) };
|
||||
app.tool_timeout = Some(60);
|
||||
app.load_envs();
|
||||
assert_eq!(app.tool_timeout, Some(60));
|
||||
|
||||
unsafe {
|
||||
match prev {
|
||||
Some(v) => env::set_var(&env_name, v),
|
||||
None => env::remove_var(&env_name),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn editor_returns_configured_value() {
|
||||
let configured =
|
||||
|
||||
Reference in new issue
Block a user