(
code_config: &CodeConfig,
opts: &SessionOptions,
session_id: Option<&str>,
)
| 29 | } |
| 30 | |
| 31 | pub(super) fn resolve_session_llm_client( |
| 32 | code_config: &CodeConfig, |
| 33 | opts: &SessionOptions, |
| 34 | session_id: Option<&str>, |
| 35 | ) -> Result<Arc<dyn LlmClient>> { |
| 36 | // A host-supplied client overrides the provider-string factory entirely: |
| 37 | // the host owns the full Action-layer dependency (custom provider, replay |
| 38 | // client, proxy/audit wrapper). Config-based model resolution is bypassed. |
| 39 | if let Some(ref client) = opts.llm_client { |
| 40 | return Ok(Arc::clone(client)); |
| 41 | } |
| 42 | |
| 43 | let model_ref = if let Some(ref model) = opts.model { |
| 44 | model.as_str() |
| 45 | } else { |
| 46 | if opts.temperature.is_some() || opts.thinking_budget.is_some() { |
| 47 | tracing::warn!( |
| 48 | "temperature/thinking_budget set without model override - these will be ignored. \ |
| 49 | Use with_model() to apply LLM parameter overrides." |
| 50 | ); |
| 51 | } |
| 52 | code_config |
| 53 | .default_model |
| 54 | .as_deref() |
| 55 | .context("default_model must be set in 'provider/model' format")? |
| 56 | }; |
| 57 | |
| 58 | let (provider_name, model_id) = model_ref |
| 59 | .split_once('/') |
| 60 | .context("model format must be 'provider/model' (e.g., 'openai/gpt-4o')")?; |
| 61 | |
| 62 | let mut llm_config = code_config |
| 63 | .llm_config(provider_name, model_id) |
| 64 | .with_context(|| { |
| 65 | format!("provider '{provider_name}' or model '{model_id}' not found in config") |
| 66 | })?; |
| 67 | |
| 68 | if opts.model.is_some() { |
| 69 | if let Some(temp) = opts.temperature { |
| 70 | llm_config = llm_config.with_temperature(temp); |
| 71 | } |
| 72 | if let Some(budget) = opts.thinking_budget { |
| 73 | llm_config = llm_config.with_thinking_budget(budget); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | if let Some(session_id) = session_id { |
| 78 | llm_config = llm_config.with_session_id(session_id); |
| 79 | } |
| 80 | |
| 81 | Ok(crate::llm::create_client_with_config(llm_config)) |
| 82 | } |
| 83 | |
| 84 | pub(super) struct ResolvedSessionMemory { |
| 85 | pub(super) memory: Option<Arc<crate::memory::AgentMemory>>, |
no test coverage detected