fix: preserve delivered page links when auto images fail

This commit is contained in:
john
2026-07-24 17:57:39 +08:00
parent 412e5f149b
commit 550969bed2
6 changed files with 152 additions and 5 deletions
+65
View File
@@ -743,6 +743,71 @@ test('static page run succeeds when workspace fallback reports the current HTML
assert.ok(Number(observedRunStartedAtMs) > 0);
});
test('auto image generation failure does not fail a delivered static page', async () => {
const pool = createFakePool({
sessionDeliverables: {
'user-1:session-poem-page': [{
page_id: 'page-poem',
title: '山居秋夜',
workspace_relative_path: 'public/shan-ju-qiu-ye.html',
}],
},
});
const gateway = createAgentRunGateway({
pool,
userAuth: {},
chatIntentRouter: {
isEnabled() {
return true;
},
async classify() {
return {
route: 'agent_orchestration',
confidence: 0.95,
reason: '内容页生成意图',
suggestedSkill: 'static-page-publish',
imageGeneration: { mode: 'auto', source: 'intent' },
};
},
applyAgentOrchestration(message) {
return message;
},
},
tkmindProxy: {
async startSessionForUser() {
return { id: 'session-poem-page' };
},
async submitSessionReplyAndAwaitFinishForUser() {
return {
ok: true,
finishEvent: { type: 'Finish' },
toolEvidence: {
calls: ['sandbox-fs__generate_image', 'sandbox-fs__write_file'],
generateImage: { called: true, succeeded: false },
},
};
},
},
syncUserPagesOnSuccess: async () => ({ pageDataBind: { errors: [] } }),
retryDelaysMs: [],
});
const run = await gateway.createRun('user-1', {
requestId: 'req-poem-page',
userMessage: {
role: 'user',
content: [{ type: 'text', text: '帮我写一首诗词,做个页面吧' }],
metadata: {
displayText: '帮我写一首诗词,做个页面吧',
memindRun: { imageGenerationMode: 'auto' },
},
},
});
await waitFor(() => pool.runs.get(run.id)?.status === 'succeeded');
assert.equal(pool.runs.get(run.id).error_message, null);
});
test('agent run uses direct chat service for eligible chat messages', async () => {
const pool = createFakePool();
const directRuns = [];