How Magpie classifies tasks into Simple, Standard, and BugFix to choose the right blueprint
Before running the agent, Magpie classifies each task to determine which blueprint path to execute. This ensures the right workflow runs for each type of work.
pub async fn classify_task( task: &str, dry_run: bool, trace_dir: Option<&PathBuf>,) -> TaskComplexity { let lower = task.to_lowercase(); // Fast path: simple keywords (checked first — "fix typo" is Simple, not BugFix) if SIMPLE_KEYWORDS.iter().any(|kw| lower.contains(kw)) { info!(task, "classified as Simple (keyword match)"); return TaskComplexity::Simple; } // Fast path: bugfix keywords if BUGFIX_KEYWORDS.iter().any(|kw| lower.contains(kw)) { info!(task, "classified as BugFix (keyword match)"); return TaskComplexity::BugFix; } // Fast path: standard keywords if STANDARD_KEYWORDS.iter().any(|kw| lower.contains(kw)) { info!(task, "classified as Standard (keyword match)"); return TaskComplexity::Standard; } // Ambiguous — use Claude to classify (or default to Simple in dry_run) if dry_run { info!(task, "ambiguous task in dry_run → defaulting to Simple"); return TaskComplexity::Simple; } info!(task, "ambiguous task → asking Claude to classify"); let prompt = format!( "Classify this task as either SIMPLE, STANDARD, or BUGFIX.\n\n\ SIMPLE = documentation changes, typo fixes, renames, formatting, trivial edits.\n\ STANDARD = new features, refactors, integrations, anything that needs tests.\n\ BUGFIX = fixing bugs, crashes, errors, regressions, investigating broken behavior.\n\n\ Task: {task}\n\n\ Reply with ONLY the word SIMPLE, STANDARD, or BUGFIX, nothing else." ); match claude_call(&prompt, "classify", trace_dir).await { Ok(response) => { let upper = response.trim().to_uppercase(); if upper.contains("SIMPLE") { info!(task, "agent classified as Simple"); TaskComplexity::Simple } else if upper.contains("BUGFIX") { info!(task, "agent classified as BugFix"); TaskComplexity::BugFix } else { info!(task, "agent classified as Standard (default for ambiguous)"); TaskComplexity::Standard } } Err(e) => { warn!(task, error = %e, "classification claude_call failed → defaulting to Standard"); TaskComplexity::Standard } }}