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 })