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", "/?"):
|
elif cmd in ("/help", "/h", "/?"):
|
||||||
return _cmd_help()
|
return _cmd_help()
|
||||||
else:
|
else:
|
||||||
return f"Unknown command: {cmd}\n\n{_cmd_help()}"
|
return None
|
||||||
|
|
||||||
|
|
||||||
async def _cmd_new(user_id: str, args: str) -> str:
|
async def _cmd_new(user_id: str, args: str) -> str:
|
||||||
|
|||||||
@ -55,12 +55,6 @@ Guidelines:
|
|||||||
MAX_ITERATIONS = 10
|
MAX_ITERATIONS = 10
|
||||||
_TOOL_MAP = {t.name: t for t in TOOLS}
|
_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:
|
class OrchestrationAgent:
|
||||||
"""Per-user agent with conversation history and active session tracking."""
|
"""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.info(">>> user=...%s conv=%s msg=%r", short_uid, active_conv, text[:80])
|
||||||
logger.debug(" history_len=%d", len(self._history[user_id]))
|
logger.debug(" history_len=%d", len(self._history[user_id]))
|
||||||
|
|
||||||
# Passthrough mode: if active session and not a command, bypass LLM
|
# Passthrough mode: if active session, bypass LLM (bot commands handled earlier)
|
||||||
if active_conv and not _looks_like_command(text):
|
if active_conv:
|
||||||
try:
|
try:
|
||||||
reply = await manager.send(active_conv, text, user_id=user_id)
|
reply = await manager.send(active_conv, text, user_id=user_id)
|
||||||
logger.info("<<< [passthrough] reply: %r", reply[:120])
|
logger.info("<<< [passthrough] reply: %r", reply[:120])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user