fix(static): 子智能体停止请求携带 conversation_id,修复误报无权限

terminateSubAgent/stopAllAgents 此前不带 conversation_id,with_terminal
落到工作区级服务 terminal,其 current_conversation_id 是最近加载的对话,
与目标任务所属对话不一致时后端返回 403「无权限停止该子智能体任务」。
补上后会请求命中对话级 terminal,权限校验通过,且终结操作直接作用于
持有活实例的 manager(优先直接 cancel,不再依赖 control.json 兜底)。
This commit is contained in:
JOJO 2026-07-21 16:16:41 +08:00
parent a1a9a47446
commit 794742e981

View File

@ -169,7 +169,12 @@ export const useSubAgentStore = defineStore('subAgent', {
[normalizedId]: true
};
try {
const resp = await fetch(`/api/sub_agents/${encodeURIComponent(normalizedId)}/terminate`, {
// 必须携带 conversation_idwith_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 })