From 77da90e316a0813da6637f7283b0433a26ecb4a7 Mon Sep 17 00:00:00 2001 From: zhayujie Date: Mon, 15 Jun 2026 17:51:22 +0800 Subject: [PATCH] feat: record self-evolution turn on streaming chat --- agent/chat/service.py | 18 ++++++++++++++++++ docker/docker-compose.yml | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/agent/chat/service.py b/agent/chat/service.py index 7520a13b..ca8f8647 100644 --- a/agent/chat/service.py +++ b/agent/chat/service.py @@ -274,6 +274,11 @@ class ChatService: # Execute post-process tools agent._execute_post_process_tools() + # Record this user turn for the self-evolution idle trigger. This + # streaming path bypasses agent_bridge.agent_reply, so the activity must + # be noted here, otherwise idle scans never see any signal to evolve. + self._note_evolution_turn(agent, context) + logger.info(f"[ChatService] Agent run completed: session={session_id}") @@ -309,6 +314,19 @@ class ChatService: except Exception as e: logger.warning(f"[ChatService] Failed to attach context to scheduler: {e}") + @staticmethod + def _note_evolution_turn(agent, context): + """Record a user turn so the self-evolution idle trigger has signal.""" + try: + from agent.evolution.trigger import note_user_turn + ch = (context.get("channel_type") or "") if context else "" + rcv = (context.get("receiver") or "") if context else "" + is_group = bool(context.get("isgroup")) if context else False + # Only single chats get a proactive push target; group push is noisy. + note_user_turn(agent, channel_type=ch, receiver=(rcv if not is_group else "")) + except Exception: + pass + @staticmethod def _persist_messages(session_id: str, new_messages: list, channel_type: str = ""): try: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 6e5dfde7..7e5c4e6b 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -38,12 +38,13 @@ services: DINGTALK_CLIENT_SECRET: '' WECOM_BOT_ID: '' WECOM_BOT_SECRET: '' - # 如需通过宿主机访问 Web 控制台,改为 '0.0.0.0' 并设置 WEB_PASSWORD + # To access the web console from the host, set this to '0.0.0.0' and set WEB_PASSWORD WEB_HOST: '127.0.0.1' WEB_PASSWORD: '' AGENT: 'True' AGENT_MAX_CONTEXT_TOKENS: 50000 AGENT_MAX_CONTEXT_TURNS: 20 AGENT_MAX_STEPS: 20 + SELF_EVOLUTION_ENABLED: 'True' volumes: - ./cow:/home/agent/cow