fix: add goose execution override for h5 chat

This commit is contained in:
john
2026-07-04 14:48:45 +08:00
parent 927e16d861
commit 12268110f7
13 changed files with 261 additions and 18 deletions
+30
View File
@@ -301,6 +301,36 @@ test('agent run uses direct chat service for eligible chat messages', async () =
assert.ok(pool.events.some((event) => event.eventType === 'direct_chat_completed'));
});
test('agent run escalates direct sessions to a new goose session when forced', async () => {
const pool = createFakePool();
const submitted = [];
const gateway = createAgentRunGateway({
pool,
tkmindProxy: {
async startSessionForUser(userId) {
assert.equal(userId, 'user-1');
return { id: 'goose-session-1' };
},
async submitSessionReplyForUser(userId, sessionId, requestId, userMessage, options = {}) {
submitted.push({ userId, sessionId, requestId, userMessage, options });
},
},
retryDelaysMs: [],
});
const run = await gateway.createRun('user-1', {
sessionId: 'h5direct_existing',
requestId: 'req-force-goose',
userMessage: { role: 'user', content: [{ type: 'text', text: '帮我生成页面 public/a.html' }] },
forceGoose: true,
});
await waitFor(() => pool.runs.get(run.id)?.status === 'succeeded');
assert.equal(pool.runs.get(run.id).agent_session_id, 'goose-session-1');
assert.equal(submitted[0].sessionId, 'goose-session-1');
assert.ok(pool.events.some((event) => event.eventType === 'direct_session_escalated_to_goose'));
});
test('agent run with code tool mode starts and submits with code policy', async () => {
const pool = createFakePool();
const submitted = [];