(prompt: &str, name: &str)
| 223 | } |
| 224 | |
| 225 | fn contains_explicit_reference(prompt: &str, name: &str) -> bool { |
| 226 | let direct_mentions = [ |
| 227 | format!("@{name}"), |
| 228 | format!("@\"{name}"), |
| 229 | format!("@'{name}"), |
| 230 | format!("{name} (agent)"), |
| 231 | ]; |
| 232 | if direct_mentions |
| 233 | .iter() |
| 234 | .any(|needle| contains_bounded(prompt, needle)) |
| 235 | { |
| 236 | return true; |
| 237 | } |
| 238 | |
| 239 | [ |
| 240 | format!("use {name} subagent"), |
| 241 | format!("use the {name} subagent"), |
| 242 | format!("use {name} agent"), |
| 243 | format!("use the {name} agent"), |
| 244 | format!("delegate to {name}"), |
| 245 | format!("ask {name}"), |
| 246 | format!("ask the {name}"), |
| 247 | format!("使用{name}"), |
| 248 | format!("使用 {name}"), |
| 249 | format!("用{name}"), |
| 250 | format!("用 {name}"), |
| 251 | ] |
| 252 | .iter() |
| 253 | .any(|needle| contains_bounded(prompt, needle)) |
| 254 | } |
| 255 | |
| 256 | fn contains_bounded(text: &str, needle: &str) -> bool { |
| 257 | text.match_indices(needle).any(|(idx, _)| { |
no test coverage detected