diff --git a/app/intent.py b/app/intent.py index 7dbb5fe..9e40060 100644 --- a/app/intent.py +++ b/app/intent.py @@ -64,14 +64,30 @@ def classify_intent(message: str) -> str: # Open WebUI background tasks — sent automatically after every chat response. # They include the full chat history, so they'd mis-trigger execute/task intents. - # Patterns: "### Task:", "Query: " (query augmentation), meta-task keywords. + + # Pattern 1: OW meta-task headers and keyword phrases if (msg.startswith("### task:") or msg.startswith("query:") or "chat history" in msg or "summarizing the chat" in msg or "categorizing the main themes" in msg or "follow-up questions" in msg or - "3-5 word title" in msg): + "3-5 word title" in msg or + "provided context" in msg or + "following conversation" in msg or + "based on the conversation" in msg): + return "planning" + + # Pattern 2: conversation history dumps — contain role marker pairs. + # Real user messages never contain both "user:" and "assistant:" labels. + if "user:" in msg and "assistant:" in msg: + return "planning" + if msg.count("user:") >= 2 or msg.count("assistant:") >= 2: + return "planning" + + # Pattern 3: OW markdown template headers (### ) in long messages. + # Real mobile messages don't use markdown section headers. + if "### " in msg and len(msg) > 200: return "planning" # Project creation — check before task/query