Classify task complexity to determine recursion depth. Returns: "minimal" — Q&A, short lookups. No recursion. "standard" — Typical single-file coding tasks. 1 critique+refine pass. "deep" — Multi-file, complex APIs, long tasks. 2 critique+refine passes.
(user_message: str)
| 73 | |
| 74 | |
| 75 | def classify_breadth_need(user_message: str) -> str: |
| 76 | """ |
| 77 | Classify task complexity to determine recursion depth. |
| 78 | |
| 79 | Returns: |
| 80 | "minimal" — Q&A, short lookups. No recursion. |
| 81 | "standard" — Typical single-file coding tasks. 1 critique+refine pass. |
| 82 | "deep" — Multi-file, complex APIs, long tasks. 2 critique+refine passes. |
| 83 | """ |
| 84 | msg = user_message.strip().lower() |
| 85 | words = msg.split() |
| 86 | |
| 87 | # Very short messages that look like questions → minimal |
| 88 | if len(words) < 8: |
| 89 | if (msg.endswith("?") |
| 90 | or msg.startswith(_QA_STARTERS) |
| 91 | or any(k in msg for k in _QA_PHRASES)): |
| 92 | return "minimal" |
| 93 | |
| 94 | # No action keywords → likely Q&A → minimal |
| 95 | has_action = any(k in msg for k in _ACTION_KEYWORDS) |
| 96 | if not has_action: |
| 97 | return "minimal" |
| 98 | |
| 99 | # Long messages or many deep-complexity signals → deep |
| 100 | deep_count = sum(1 for sig in _DEEP_SIGNALS if sig in msg) |
| 101 | if len(words) > 50 or deep_count >= 3: |
| 102 | return "deep" |
| 103 | |
| 104 | return "standard" |
| 105 | |
| 106 | |
| 107 | # ── Adaptive depth (Phase 8) ──────────────────────────────────────────────── |
no outgoing calls