fix: unblock agent events after portal direct chat escalation
When a session starts with LLM direct chat then escalates to goosed, invalidate the portal-direct-chat snapshot and stop replaying stale SSE so page-generation turns stream and finish correctly. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -224,6 +224,7 @@ export function createAgentRunGateway({
|
||||
toolGateway = null,
|
||||
directChatService = null,
|
||||
chatIntentRouter = null,
|
||||
sessionSnapshotService = null,
|
||||
retryDelaysMs = DEFAULT_RUN_RETRY_DELAYS_MS,
|
||||
autoDispatch = envFlag(process.env.MEMIND_AGENT_RUN_AUTODISPATCH, true),
|
||||
maxConcurrentRuns = positiveInteger(
|
||||
@@ -409,6 +410,11 @@ export function createAgentRunGateway({
|
||||
return Array.isArray(caps?.grantedSkills) ? caps.grantedSkills : [];
|
||||
}
|
||||
|
||||
async function invalidatePortalDirectChatSnapshot(sessionId) {
|
||||
if (!sessionId || isDirectChatSessionId(sessionId) || !sessionSnapshotService?.remove) return;
|
||||
await sessionSnapshotService.remove(sessionId).catch(() => {});
|
||||
}
|
||||
|
||||
async function resolveRunRouting(row, userMessage, runOptions) {
|
||||
if (!chatIntentRouter?.classify) return null;
|
||||
const enabled = chatIntentRouter.isEnabled
|
||||
@@ -497,6 +503,7 @@ export function createAgentRunGateway({
|
||||
const workingDir = userAuth?.resolveWorkingDir
|
||||
? await userAuth.resolveWorkingDir(row.user_id)
|
||||
: undefined;
|
||||
await invalidatePortalDirectChatSnapshot(row.agent_session_id ?? null);
|
||||
await appendEvent(runId, 'tool_gateway_dispatch', {
|
||||
protocol: toolGatewayStatus.protocol ?? 'agent-run-v1',
|
||||
taskType: runOptions.taskType,
|
||||
@@ -563,6 +570,7 @@ export function createAgentRunGateway({
|
||||
});
|
||||
}
|
||||
|
||||
await invalidatePortalDirectChatSnapshot(sessionId);
|
||||
await tkmindProxy.submitSessionReplyForUser(
|
||||
row.user_id,
|
||||
sessionId,
|
||||
|
||||
Reference in New Issue
Block a user