From 5d55d01f408b7276a6479854ac67dbe0cac8b3d7 Mon Sep 17 00:00:00 2001 From: "Yuyao Huang (Sam)" Date: Sat, 28 Mar 2026 12:18:41 +0800 Subject: [PATCH] =?UTF-8?q?refactor(commands):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=9C=AA=E7=9F=A5=E5=91=BD=E4=BB=A4=E5=A4=84=E7=90=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=B8=BA=E8=BF=94=E5=9B=9ENone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除orchestrator/agent.py中不再需要的命令检测逻辑,因命令处理已提前在bot/commands.py中完成 --- bot/commands.py | 2 +- orchestrator/agent.py | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/bot/commands.py b/bot/commands.py index bd7552d..93b6ac3 100644 --- a/bot/commands.py +++ b/bot/commands.py @@ -56,7 +56,7 @@ async def handle_command(user_id: str, text: str) -> Optional[str]: elif cmd in ("/help", "/h", "/?"): return _cmd_help() else: - return f"Unknown command: {cmd}\n\n{_cmd_help()}" + return None async def _cmd_new(user_id: str, args: str) -> str: diff --git a/orchestrator/agent.py b/orchestrator/agent.py index 2b8d62f..2e62071 100644 --- a/orchestrator/agent.py +++ b/orchestrator/agent.py @@ -55,12 +55,6 @@ Guidelines: MAX_ITERATIONS = 10 _TOOL_MAP = {t.name: t for t in TOOLS} -COMMAND_PATTERN = re.compile(r"^/(new|list|close|switch|retry|help)", re.IGNORECASE) - - -def _looks_like_command(text: str) -> bool: - return bool(COMMAND_PATTERN.match(text.strip())) - class OrchestrationAgent: """Per-user agent with conversation history and active session tracking.""" @@ -108,8 +102,8 @@ class OrchestrationAgent: logger.info(">>> user=...%s conv=%s msg=%r", short_uid, active_conv, text[:80]) logger.debug(" history_len=%d", len(self._history[user_id])) - # Passthrough mode: if active session and not a command, bypass LLM - if active_conv and not _looks_like_command(text): + # Passthrough mode: if active session, bypass LLM (bot commands handled earlier) + if active_conv: try: reply = await manager.send(active_conv, text, user_id=user_id) logger.info("<<< [passthrough] reply: %r", reply[:120])