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

Method detect_with_confidence

core/src/prompts.rs:256–345  ·  view source on GitHub ↗

Detects the most appropriate agent style based on user message content, along with a confidence level. This is a local fallback for environments where LLM pre-analysis is unavailable. Normal execution uses structured pre-analysis first.

(message: &str)

Source from the content-addressed store, hash-verified

254 /// This is a local fallback for environments where LLM pre-analysis is
255 /// unavailable. Normal execution uses structured pre-analysis first.
256 pub fn detect_with_confidence(message: &str) -> (Self, DetectionConfidence) {
257 // Chinese text has high ambiguity in intent classification due to
258 // compound verb structures and context-dependent meaning.
259 // Bypass keyword matching entirely and route to LLM classification.
260 if message
261 .chars()
262 .any(|c| ('\u{4e00}'..='\u{9fff}').contains(&c))
263 {
264 return (AgentStyle::GeneralPurpose, DetectionConfidence::Low);
265 }
266
267 let lower = message.to_lowercase();
268
269 // === HIGH CONFIDENCE: Very specific patterns ===
270
271 // Strong verification indicators
272 if lower.contains("try to break")
273 || lower.contains("find vulnerabilities")
274 || lower.contains("adversarial")
275 || lower.contains("security audit")
276 {
277 return (AgentStyle::Verification, DetectionConfidence::High);
278 }
279
280 // Strong plan indicators
281 if lower.contains("help me plan")
282 || lower.contains("help me design")
283 || lower.contains("create a plan")
284 || lower.contains("implementation plan")
285 || lower.contains("step-by-step plan")
286 {
287 return (AgentStyle::Plan, DetectionConfidence::High);
288 }
289
290 // Strong exploration indicators
291 if lower.contains("find all files")
292 || lower.contains("search for all")
293 || lower.contains("locate all")
294 {
295 return (AgentStyle::Explore, DetectionConfidence::High);
296 }
297
298 // === MEDIUM CONFIDENCE: Specific but less definitive ===
299
300 // Verification keywords
301 if lower.contains("verify")
302 || lower.contains("verification")
303 || lower.contains("break")
304 || lower.contains("debug")
305 || lower.contains("test")
306 || lower.contains("check if")
307 {
308 return (AgentStyle::Verification, DetectionConfidence::Medium);
309 }
310
311 // Plan keywords
312 if lower.contains("plan")
313 || lower.contains("design")

Callers

nothing calls this directly

Calls 1

containsMethod · 0.80

Tested by

no test coverage detected