(input: SessionDataSnapshotInput<'_>)
| 255 | } |
| 256 | |
| 257 | async fn build_session_data_snapshot(input: SessionDataSnapshotInput<'_>) -> SessionData { |
| 258 | let confirmation_policy = match &input.config.confirmation_manager { |
| 259 | Some(manager) => Some(manager.policy().await), |
| 260 | None => input.config.confirmation_policy.clone(), |
| 261 | }; |
| 262 | let model_name = persisted_model_name(input.model_name); |
| 263 | let now = chrono::Utc::now().timestamp(); |
| 264 | |
| 265 | SessionData { |
| 266 | id: input.session_id.to_string(), |
| 267 | config: crate::store::SessionConfig { |
| 268 | name: String::new(), |
| 269 | workspace: input.workspace.display().to_string(), |
| 270 | system_prompt: Some(input.config.prompt_slots.build()), |
| 271 | max_context_length: input.config.max_context_tokens.min(u32::MAX as usize) as u32, |
| 272 | auto_compact: input.config.auto_compact, |
| 273 | auto_compact_threshold: input.config.auto_compact_threshold, |
| 274 | storage_type: crate::config::StorageBackend::File, |
| 275 | queue_config: input.config.queue_config.clone(), |
| 276 | confirmation_policy, |
| 277 | permission_policy: input.config.permission_policy.clone(), |
| 278 | enforce_active_skill_tool_restrictions: input |
| 279 | .config |
| 280 | .enforce_active_skill_tool_restrictions, |
| 281 | max_parallel_tasks: Some(input.config.max_parallel_tasks), |
| 282 | auto_delegation: Some(input.config.auto_delegation.clone()), |
| 283 | parent_id: None, |
| 284 | security_config: None, |
| 285 | hook_engine: None, |
| 286 | planning_mode: input.config.planning_mode, |
| 287 | goal_tracking: input.config.goal_tracking, |
| 288 | }, |
| 289 | state: crate::store::SessionState::Active, |
| 290 | messages: input.history, |
| 291 | context_usage: crate::store::ContextUsage::default(), |
| 292 | total_usage: crate::llm::TokenUsage::default(), |
| 293 | total_cost: 0.0, |
| 294 | model_name, |
| 295 | cost_records: Vec::new(), |
| 296 | tool_names: SessionData::tool_names_from_definitions(&input.config.tools), |
| 297 | thinking_enabled: false, |
| 298 | thinking_budget: None, |
| 299 | created_at: now, |
| 300 | updated_at: now, |
| 301 | llm_config: model_config_data(input.model_name), |
| 302 | tasks: Vec::new(), |
| 303 | parent_id: None, |
| 304 | tenant_id: input.tenant_id.map(str::to_string), |
| 305 | principal: input.principal.map(str::to_string), |
| 306 | agent_template_id: input.agent_template_id.map(str::to_string), |
| 307 | correlation_id: input.correlation_id.map(str::to_string), |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | fn persisted_model_ref(data: &SessionData) -> Option<String> { |
| 312 | if let Some(llm_config) = &data.llm_config { |
no test coverage detected