| 142 | } |
| 143 | |
| 144 | fn score_agent_for_prompt( |
| 145 | agent: &AgentDefinition, |
| 146 | prompt: &str, |
| 147 | explicit_target: Option<&str>, |
| 148 | ) -> Option<AutoDelegationTask> { |
| 149 | let lower_prompt = prompt.to_lowercase(); |
| 150 | let lower_description = agent.description.to_lowercase(); |
| 151 | let confidence = builtin_confidence(&agent.name, &lower_prompt) |
| 152 | .max(explicit_agent_confidence( |
| 153 | &agent.name, |
| 154 | &lower_prompt, |
| 155 | explicit_target, |
| 156 | )) |
| 157 | .max(description_confidence(&lower_description, &lower_prompt)); |
| 158 | |
| 159 | (confidence > 0.0).then(|| AutoDelegationTask { |
| 160 | agent: agent.name.clone(), |
| 161 | description: auto_description(agent, prompt), |
| 162 | prompt: auto_prompt(agent, prompt), |
| 163 | confidence, |
| 164 | }) |
| 165 | } |
| 166 | |
| 167 | fn explicit_agent_target(prompt: &str, registry: &AgentRegistry) -> Option<String> { |
| 168 | let lower = prompt.to_lowercase(); |