refactor(commands): 修改未知命令处理逻辑为返回None
移除orchestrator/agent.py中不再需要的命令检测逻辑,因命令处理已提前在bot/commands.py中完成
This commit is contained in:
parent
6307deb701
commit
5d55d01f40
@ -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:
|
||||
|
||||
@ -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])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user