MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / apply_agent_config

Method apply_agent_config

crates/opencode-agent/src/agent.rs:511–604  ·  view source on GitHub ↗
(
        &mut self,
        key: &str,
        cfg: &LoadedAgentConfig,
        forced_mode: Option<AgentMode>,
    )

Source from the content-addressed store, hash-verified

509 }
510
511 fn apply_agent_config(
512 &mut self,
513 key: &str,
514 cfg: &LoadedAgentConfig,
515 forced_mode: Option<AgentMode>,
516 ) {
517 if cfg.disable.unwrap_or(false) {
518 self.agents.remove(key);
519 return;
520 }
521
522 let mut agent = self
523 .agents
524 .get(key)
525 .cloned()
526 .unwrap_or_else(|| AgentInfo::custom(key.to_string()));
527
528 if let Some(name) = &cfg.name {
529 agent.name = name.clone();
530 }
531 if let Some(description) = &cfg.description {
532 agent.description = Some(description.clone());
533 }
534 if let Some(prompt) = &cfg.prompt {
535 agent.system_prompt = Some(prompt.clone());
536 }
537 if let Some(variant) = &cfg.variant {
538 agent.variant = Some(variant.clone());
539 }
540 if let Some(temperature) = cfg.temperature {
541 agent.temperature = Some(temperature);
542 }
543 if let Some(top_p) = cfg.top_p {
544 agent.top_p = Some(top_p);
545 }
546 if let Some(color) = &cfg.color {
547 agent.color = Some(color.clone());
548 }
549 if let Some(hidden) = cfg.hidden {
550 agent.hidden = hidden;
551 }
552 if let Some(mode) = forced_mode {
553 agent.mode = mode;
554 } else if let Some(mode) = cfg.mode.clone() {
555 agent.mode = map_loaded_agent_mode(mode);
556 }
557 if let Some(steps) = cfg.steps.or(cfg.max_steps) {
558 agent.max_steps = Some(steps);
559 }
560 if let Some(max_tokens) = cfg.max_tokens {
561 agent.max_tokens = Some(max_tokens);
562 }
563 if let Some(model) = cfg.model.as_deref().and_then(parse_model_ref) {
564 agent.model_preference = Some(model.clone());
565 agent.model = Some(model);
566 }
567 if let Some(options) = &cfg.options {
568 for (key, value) in options {

Callers 1

apply_agent_configsMethod · 0.80

Calls 11

map_loaded_agent_modeFunction · 0.85
newFunction · 0.85
build_agent_rulesetFunction · 0.85
is_emptyMethod · 0.80
merge_json_valueFunction · 0.70
removeMethod · 0.45
getMethod · 0.45
cloneMethod · 0.45
get_mutMethod · 0.45

Tested by

no test coverage detected