fix(chat): stabilize web UI tool runs

This commit is contained in:
Peter Steinberger
2026-01-05 17:15:17 +00:00
parent 86c404c48b
commit b7e708c764
11 changed files with 176 additions and 45 deletions

View File

@@ -41,6 +41,7 @@ import {
type SessionEntry,
saveSessionStore,
} from "../config/sessions.js";
import { registerAgentRunContext } from "../infra/agent-events.js";
import {
loadVoiceWakeConfig,
setVoiceWakeTriggers,
@@ -844,12 +845,12 @@ export function createBridgeHandlers(ctx: BridgeHandlersContext) {
ctx.chatAbortControllers.delete(runId);
ctx.chatRunBuffers.delete(runId);
ctx.chatDeltaSentAt.delete(runId);
ctx.removeChatRun(active.sessionId, runId, sessionKey);
ctx.removeChatRun(runId, runId, sessionKey);
const payload = {
runId,
sessionKey,
seq: (ctx.agentRunSeq.get(active.sessionId) ?? 0) + 1,
seq: (ctx.agentRunSeq.get(runId) ?? 0) + 1,
state: "aborted" as const,
};
ctx.broadcast("chat", payload);
@@ -940,6 +941,7 @@ export function createBridgeHandlers(ctx: BridgeHandlersContext) {
lastTo: entry?.lastTo,
};
const clientRunId = p.idempotencyKey;
registerAgentRunContext(clientRunId, { sessionKey: p.sessionKey });
const cached = ctx.dedupe.get(`chat:${clientRunId}`);
if (cached) {
@@ -962,7 +964,7 @@ export function createBridgeHandlers(ctx: BridgeHandlersContext) {
sessionId,
sessionKey: p.sessionKey,
});
ctx.addChatRun(sessionId, {
ctx.addChatRun(clientRunId, {
sessionKey: p.sessionKey,
clientRunId,
});
@@ -978,6 +980,7 @@ export function createBridgeHandlers(ctx: BridgeHandlersContext) {
{
message: messageWithAttachments,
sessionId,
runId: clientRunId,
thinking: p.thinking,
deliver: p.deliver,
timeout: Math.ceil(timeoutMs / 1000).toString(),