MCPcopy Create free account
hub / github.com/AI45Lab/Code / apply_to

Method apply_to

core/src/subagent.rs:500–539  ·  view source on GitHub ↗

Apply this definition's declared configuration to a mutable AgentConfig. Follows the "host overrides win" principle: only fills fields that are currently at their default/None state. Callers who want to force values should set them *after* calling `apply_to`.

(&self, config: &mut crate::agent::AgentConfig)

Source from the content-addressed store, hash-verified

498 /// currently at their default/None state. Callers who want to force values
499 /// should set them *after* calling `apply_to`.
500 pub(crate) fn apply_to(&self, config: &mut crate::agent::AgentConfig) {
501 use std::sync::Arc;
502
503 if config.permission_checker.is_none() && self.has_defined_permissions() {
504 config.permission_checker =
505 Some(Arc::new(self.permissions.clone()) as Arc<dyn PermissionChecker>);
506 config.permission_policy = Some(self.permissions.clone());
507 }
508
509 if let Some(ref prompt) = self.prompt {
510 if config.prompt_slots.extra.is_none() {
511 config.prompt_slots.extra = Some(prompt.clone());
512 }
513 }
514
515 if let Some(max_steps) = self.max_steps {
516 if config.max_tool_rounds == crate::agent::MAX_TOOL_ROUNDS {
517 config.max_tool_rounds = max_steps;
518 }
519 }
520
521 // Confirmation inheritance: resolve Ask decisions in child runs.
522 if config.confirmation_manager.is_none() {
523 let inheritance = self.confirmation_inheritance.clone().unwrap_or_else(|| {
524 if self.has_defined_permissions() {
525 ConfirmationInheritance::AutoApprove
526 } else {
527 ConfirmationInheritance::DenyOnAsk
528 }
529 });
530 match inheritance {
531 ConfirmationInheritance::AutoApprove => {
532 config.confirmation_manager =
533 Some(Arc::new(crate::hitl::AutoApproveConfirmation));
534 }
535 ConfirmationInheritance::DenyOnAsk => { /* leave None — safety_gate denies */ }
536 ConfirmationInheritance::InheritParent => { /* caller passes parent's manager */ }
537 }
538 }
539 }
540
541 /// Set confirmation inheritance policy for child runs.
542 pub fn with_confirmation(mut self, inheritance: ConfirmationInheritance) -> Self {

Calls 2

cloneMethod · 0.45