MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / is_complex

Function is_complex

core/orchestrator.py:48–115  ·  view source on GitHub ↗

Heuristic: does this need multiple steps? Uses keyword matching, conversational pattern detection, and message length to determine if a request should trigger orchestration. Args: message: User's request text Returns: True if request should be

(message)

Source from the content-addressed store, hash-verified

46]
47
48def is_complex(message):
49 """
50 Heuristic: does this need multiple steps?
51
52 Uses keyword matching, conversational pattern detection, and message length
53 to determine if a request should trigger orchestration.
54
55 Args:
56 message: User's request text
57
58 Returns:
59 True if request should be orchestrated, False otherwise
60 """
61 msg = message.lower()
62
63 # Action keywords that indicate a task (not a question)
64 # Keep in sync with _action_kws in core/agent.py
65 _action_kws = [
66 "create", "write", "make", "build", "edit", "fix", "run", "execute",
67 "install", "add", "delete", "remove", "update", "patch", "refactor",
68 "implement", "generate", "rewrite", "deploy", "setup", "configure",
69 "review", "analyze", "analyse", "audit", "examine", "inspect", "assess",
70 "read", "look at", "show me", "check",
71 "replace", "rename", "swap", "convert", "change", "append", "insert",
72 "move", "copy", "print", "output", "display", "open",
73 "remember", "don't forget", "forget",
74 "ask gemini", "ask claude", "call gemini", "call claude",
75 ]
76 _has_action = any(re.search(r'\b' + re.escape(k) + r'\b', msg) for k in _action_kws)
77
78 # Question starters that indicate Q&A (not a task)
79 _question_starters = (
80 "what", "why", "how", "when", "where", "who", "which",
81 "is ", "are ", "do ", "does ", "can ", "could ", "would ",
82 "should ", "will ", "was ", "were ", "has ", "have ",
83 )
84 _qa_phrases = [
85 "tell me", "tell me about", "explain", "help me understand",
86 "what can you", "hello", "hi", "hey", "thanks", "thank you",
87 ]
88
89 # If no action keyword AND looks like a question, NOT complex
90 if not _has_action and (
91 msg.endswith("?") or
92 msg.startswith(_question_starters) or
93 any(re.search(r'\b' + re.escape(k) + r'\b', msg) for k in _qa_phrases)
94 ):
95 return False
96
97 # Check for conversational patterns (even with action keywords)
98 if any(pattern in msg for pattern in CONVERSATIONAL_PATTERNS):
99 return False
100
101 # Short messages are rarely complex
102 if len(message) < 50:
103 return False
104
105 # Count positive signals

Calls 1

searchMethod · 0.45