fix(code-agent): always forward AgentRun cancel (#1867)

This commit is contained in:
Lyon
2026-06-22 10:57:39 +08:00
committed by GitHub
parent 14db08d7fa
commit 0be7db0100
2 changed files with 0 additions and 32 deletions
@@ -866,33 +866,6 @@ export async function cancelAgentRunChatTurn({ traceId, currentResult = null, op
HWLAB_CODE_AGENT_CANCEL_TIMEOUT_MS: String(cancelTimeoutMs)
}
};
const localTerminal = agentRunCancelTerminalStatus(mapped);
if (localTerminal) return agentRunAlreadyTerminalCancelPayload({ traceId, payload: mapped, terminalStatus: localTerminal, options, traceStore });
try {
const guard = await syncAgentRunChatResult({
traceId,
currentResult: mapped,
options: { ...cancelOptions, deferAgentRunResultSync: false },
traceStore,
forceResultSync: true,
refreshEvents: true
});
const guarded = guard?.result ?? null;
const guardedTerminal = agentRunCancelTerminalStatus(guarded);
if (guardedTerminal) return agentRunAlreadyTerminalCancelPayload({ traceId, payload: guarded, terminalStatus: guardedTerminal, options, traceStore });
} catch (error) {
traceStore.append(traceId, agentRunTraceEvent({
type: "cancel",
status: "running",
label: "agentrun:cancel:terminal_guard_failed",
errorCode: error?.code ?? "agentrun_cancel_terminal_guard_failed",
message: "HWLAB could not confirm AgentRun terminal state before forwarding cancel; continuing with cancel because no terminal authority was observed.",
runId: mapped.agentRun.runId,
commandId: mapped.agentRun.commandId,
waitingFor: "cancel-terminal-guard",
valuesPrinted: false
}, mapped.agentRun));
}
const fetchImpl = options.fetchImpl ?? globalThis.fetch;
const managerUrl = resolveAgentRunManagerUrl(env, mapped.agentRun.managerUrl);
await agentRunJson(fetchImpl, managerUrl, `/api/v1/commands/${encodeURIComponent(mapped.agentRun.commandId)}/cancel`, {
-5
View File
@@ -2503,11 +2503,6 @@ export async function handleCodeAgentCancelHttp(request, response, options) {
}));
return;
}
const alreadyTerminal = await syncAlreadyTerminalAgentRunBeforeCancel({ traceId, currentResult, params, options, traceStore });
if (alreadyTerminal) {
sendJson(response, 200, alreadyTerminal);
return;
}
const payload = await cancelAgentRunChatTurn({ traceId, currentResult, options, traceStore });
if (payload) {
if (payload.alreadyTerminal === true || isTraceCommandTerminalStatus(payload.status)) {