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:
@@ -383,6 +383,63 @@ test('agent run uses direct chat on regular agent sessions when llm routes direc
|
||||
assert.ok(pool.events.some((event) => event.eventType === 'direct_chat_completed'));
|
||||
});
|
||||
|
||||
test('agent run invalidates portal direct chat snapshot before submitting to goosed', async () => {
|
||||
const pool = createFakePool();
|
||||
const submitted = [];
|
||||
const invalidated = [];
|
||||
const gateway = createAgentRunGateway({
|
||||
pool,
|
||||
userAuth: {
|
||||
async getUserCapabilities() {
|
||||
return { grantedSkills: ['static-page-publish'] };
|
||||
},
|
||||
},
|
||||
tkmindProxy: {
|
||||
async submitSessionReplyForUser(userId, sessionId, requestId, userMessage) {
|
||||
submitted.push({ userId, sessionId, requestId, userMessage });
|
||||
},
|
||||
},
|
||||
chatIntentRouter: {
|
||||
isEnabled() {
|
||||
return true;
|
||||
},
|
||||
async classify() {
|
||||
return {
|
||||
route: 'agent_orchestration',
|
||||
confidence: 1,
|
||||
reason: '用户开启深度推理',
|
||||
source: 'rule',
|
||||
};
|
||||
},
|
||||
applyAgentOrchestration(userMessage) {
|
||||
return userMessage;
|
||||
},
|
||||
},
|
||||
sessionSnapshotService: {
|
||||
async remove(sessionId) {
|
||||
invalidated.push(sessionId);
|
||||
},
|
||||
},
|
||||
retryDelaysMs: [],
|
||||
});
|
||||
|
||||
const run = await gateway.createRun('user-1', {
|
||||
sessionId: '20260704_31',
|
||||
requestId: 'req-essay-page',
|
||||
forceDeepReasoning: true,
|
||||
userMessage: {
|
||||
role: 'user',
|
||||
content: [{ type: 'text', text: '帮我写一个 200 字散文,做成页面' }],
|
||||
metadata: { displayText: '帮我写一个 200 字散文,做成页面' },
|
||||
},
|
||||
});
|
||||
|
||||
await waitFor(() => pool.runs.get(run.id)?.status === 'succeeded');
|
||||
assert.deepEqual(invalidated, ['20260704_31']);
|
||||
assert.equal(submitted.length, 1);
|
||||
assert.equal(submitted[0].sessionId, '20260704_31');
|
||||
});
|
||||
|
||||
test('agent run records direct_chat_skipped when execution is unavailable', async () => {
|
||||
const pool = createFakePool();
|
||||
const submitted = [];
|
||||
|
||||
Reference in New Issue
Block a user