fix(providers): keep runtime options backward compatible

This commit is contained in:
Chummy 2026-02-24 13:58:57 +00:00 committed by Chum Yin
parent 3a38c80c05
commit cd4d816a83
7 changed files with 19 additions and 2 deletions

View File

@ -1135,6 +1135,8 @@ pub async fn run(
zeroclaw_dir: config.config_path.parent().map(std::path::PathBuf::from),
secrets_encrypt: config.secrets.encrypt,
reasoning_enabled: config.runtime.reasoning_enabled,
custom_provider_api_mode: config.provider_api.map(|mode| mode.as_compatible_mode()),
max_tokens_override: None,
model_support_vision: config.model_support_vision,
};
@ -1595,6 +1597,8 @@ pub async fn process_message(config: Config, message: &str) -> Result<String> {
zeroclaw_dir: config.config_path.parent().map(std::path::PathBuf::from),
secrets_encrypt: config.secrets.encrypt,
reasoning_enabled: config.runtime.reasoning_enabled,
custom_provider_api_mode: config.provider_api.map(|mode| mode.as_compatible_mode()),
max_tokens_override: None,
model_support_vision: config.model_support_vision,
};
let provider: Box<dyn Provider> = providers::create_routed_provider_with_options(

View File

@ -3056,6 +3056,8 @@ pub async fn start_channels(config: Config) -> Result<()> {
zeroclaw_dir: config.config_path.parent().map(std::path::PathBuf::from),
secrets_encrypt: config.secrets.encrypt,
reasoning_enabled: config.runtime.reasoning_enabled,
custom_provider_api_mode: config.provider_api.map(|mode| mode.as_compatible_mode()),
max_tokens_override: None,
model_support_vision: config.model_support_vision,
};
let provider: Arc<dyn Provider> = Arc::from(

View File

@ -363,6 +363,8 @@ pub async fn run_gateway(host: &str, port: u16, config: Config) -> Result<()> {
zeroclaw_dir: config.config_path.parent().map(std::path::PathBuf::from),
secrets_encrypt: config.secrets.encrypt,
reasoning_enabled: config.runtime.reasoning_enabled,
custom_provider_api_mode: config.provider_api.map(|mode| mode.as_compatible_mode()),
max_tokens_override: None,
model_support_vision: config.model_support_vision,
},
)?);

View File

@ -676,6 +676,8 @@ pub struct ProviderRuntimeOptions {
pub zeroclaw_dir: Option<PathBuf>,
pub secrets_encrypt: bool,
pub reasoning_enabled: Option<bool>,
pub custom_provider_api_mode: Option<CompatibleApiMode>,
pub max_tokens_override: Option<u32>,
pub model_support_vision: Option<bool>,
}
@ -687,6 +689,8 @@ impl Default for ProviderRuntimeOptions {
zeroclaw_dir: None,
secrets_encrypt: true,
reasoning_enabled: None,
custom_provider_api_mode: None,
max_tokens_override: None,
model_support_vision: None,
}
}
@ -1426,8 +1430,7 @@ pub fn create_routed_provider_with_options(
.then_some(api_url)
.flatten();
let mut route_options = options.clone();
route_options.max_tokens_override = route.max_tokens;
let route_options = options.clone();
match create_resilient_provider_with_options(
&route.provider,

View File

@ -1034,6 +1034,7 @@ data: [DONE]
reasoning_enabled: None,
custom_provider_api_mode: None,
max_tokens_override: None,
model_support_vision: None,
};
let provider =
OpenAiCodexProvider::new(&options, None).expect("provider should initialize");

View File

@ -360,6 +360,10 @@ pub fn all_tools_with_runtime(
.map(std::path::PathBuf::from),
secrets_encrypt: root_config.secrets.encrypt,
reasoning_enabled: root_config.runtime.reasoning_enabled,
custom_provider_api_mode: root_config
.provider_api
.map(|mode| mode.as_compatible_mode()),
max_tokens_override: None,
model_support_vision: root_config.model_support_vision,
},
)

View File

@ -153,6 +153,7 @@ async fn openai_codex_second_vision_support() -> Result<()> {
reasoning_enabled: None,
custom_provider_api_mode: None,
max_tokens_override: None,
model_support_vision: None,
};
let provider = zeroclaw::providers::create_provider_with_options("openai-codex", None, &opts)?;