From 794742e9819355d1cad9f9e2c5c79cc715f40e00 Mon Sep 17 00:00:00 2001 From: JOJO <1498581755@qq.com> Date: Tue, 21 Jul 2026 16:16:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(static):=20=E5=AD=90=E6=99=BA=E8=83=BD?= =?UTF-8?q?=E4=BD=93=E5=81=9C=E6=AD=A2=E8=AF=B7=E6=B1=82=E6=90=BA=E5=B8=A6?= =?UTF-8?q?=20conversation=5Fid=EF=BC=8C=E4=BF=AE=E5=A4=8D=E8=AF=AF?= =?UTF-8?q?=E6=8A=A5=E6=97=A0=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit terminateSubAgent/stopAllAgents 此前不带 conversation_id,with_terminal 落到工作区级服务 terminal,其 current_conversation_id 是最近加载的对话, 与目标任务所属对话不一致时后端返回 403「无权限停止该子智能体任务」。 补上后会请求命中对话级 terminal,权限校验通过,且终结操作直接作用于 持有活实例的 manager(优先直接 cancel,不再依赖 control.json 兜底)。 --- static/src/stores/subAgent.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/static/src/stores/subAgent.ts b/static/src/stores/subAgent.ts index 6ee8e68a..052e58c9 100644 --- a/static/src/stores/subAgent.ts +++ b/static/src/stores/subAgent.ts @@ -169,7 +169,12 @@ export const useSubAgentStore = defineStore('subAgent', { [normalizedId]: true }; try { - const resp = await fetch(`/api/sub_agents/${encodeURIComponent(normalizedId)}/terminate`, { + // 必须携带 conversation_id:with_terminal 无会话参数时会落到工作区级服务 + // terminal,其 current_conversation_id 可能是别的对话,导致后端 403 + const conversationStore = useConversationStore(); + const convId = conversationStore.currentConversationId; + const query = convId ? `?conversation_id=${encodeURIComponent(convId)}` : ''; + const resp = await fetch(`/api/sub_agents/${encodeURIComponent(normalizedId)}/terminate${query}`, { method: 'POST' }); const data = await resp.json().catch(() => ({})); @@ -196,7 +201,11 @@ export const useSubAgentStore = defineStore('subAgent', { }, async stopAllAgents(mode: 'terminate' | 'soft_stop'): Promise<{ success: boolean; stoppedCount?: number; error?: string }> { try { - const resp = await fetch('/api/sub_agents/stop_all', { + // 同 terminateSubAgent:携带 conversation_id 确保命中对话级 terminal + const conversationStore = useConversationStore(); + const convId = conversationStore.currentConversationId; + const query = convId ? `?conversation_id=${encodeURIComponent(convId)}` : ''; + const resp = await fetch(`/api/sub_agents/stop_all${query}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ mode })