| 151 | } |
| 152 | |
| 153 | pub(super) fn apply_persisted_runtime_options( |
| 154 | mut opts: SessionOptions, |
| 155 | data: &SessionData, |
| 156 | ) -> SessionOptions { |
| 157 | opts.session_id = Some(data.id.clone()); |
| 158 | |
| 159 | if opts.model.is_none() { |
| 160 | opts.model = persisted_model_ref(data); |
| 161 | } |
| 162 | if opts.queue_config.is_none() { |
| 163 | opts.queue_config = data.config.queue_config.clone(); |
| 164 | } |
| 165 | if opts.confirmation_manager.is_none() && opts.confirmation_policy.is_none() { |
| 166 | opts.confirmation_policy = data.config.confirmation_policy.clone(); |
| 167 | } |
| 168 | if opts.permission_checker.is_none() && opts.permission_policy.is_none() { |
| 169 | if let Some(policy) = data.config.permission_policy.clone() { |
| 170 | opts = opts.with_permission_policy(policy); |
| 171 | } |
| 172 | } |
| 173 | if opts.enforce_active_skill_tool_restrictions.is_none() { |
| 174 | opts.enforce_active_skill_tool_restrictions = |
| 175 | Some(data.config.enforce_active_skill_tool_restrictions); |
| 176 | } |
| 177 | if opts.max_parallel_tasks.is_none() { |
| 178 | opts.max_parallel_tasks = data.config.max_parallel_tasks; |
| 179 | } |
| 180 | if opts.auto_delegation.is_none() { |
| 181 | opts.auto_delegation = data.config.auto_delegation.clone(); |
| 182 | } |
| 183 | |
| 184 | // Identity labels: caller-supplied values take precedence (the resume |
| 185 | // caller may want to relabel for a new tenant/principal). Otherwise |
| 186 | // restore from the persisted snapshot. |
| 187 | if opts.tenant_id.is_none() { |
| 188 | opts.tenant_id = data.tenant_id.clone(); |
| 189 | } |
| 190 | if opts.principal.is_none() { |
| 191 | opts.principal = data.principal.clone(); |
| 192 | } |
| 193 | if opts.agent_template_id.is_none() { |
| 194 | opts.agent_template_id = data.agent_template_id.clone(); |
| 195 | } |
| 196 | if opts.correlation_id.is_none() { |
| 197 | opts.correlation_id = data.correlation_id.clone(); |
| 198 | } |
| 199 | |
| 200 | opts |
| 201 | } |
| 202 | |
| 203 | pub(super) fn restore_persisted_session_state( |
| 204 | session: &AgentSession, |