fix: allow page clarification turns without delivery error

This commit is contained in:
john
2026-07-24 17:37:05 +08:00
parent 54637beffb
commit 412e5f149b
5 changed files with 103 additions and 2 deletions
+19 -2
View File
@@ -16,7 +16,11 @@ import {
SESSION_FINISHED_STALE_GRACE_MS,
tryRecoverRunFromDeliverables,
} from './agent-run-deliverable-check.mjs';
import { isPageDataIntent, isPageGenerationIntent } from './chat-skills.mjs';
import {
isGenericPageGenerationRequest,
isPageDataIntent,
isPageGenerationIntent,
} from './chat-skills.mjs';
const DEFAULT_RUN_RETRY_DELAYS_MS = [1500, 5000, 15000];
const TERMINAL_STATUSES = new Set(['succeeded', 'failed']);
@@ -66,6 +70,14 @@ function extractRunMessageText(row) {
.join('\n');
}
function extractRunDisplayText(row) {
const message = parseDbJsonColumn(row?.user_message_json, {}) ?? {};
const displayText = message?.metadata?.displayText;
return typeof displayText === 'string' && displayText.trim()
? displayText.trim()
: extractRunMessageText(row);
}
function resolveRequiredImageGeneration(row, routing) {
const message = parseDbJsonColumn(row?.user_message_json, {}) ?? {};
const metadata = message.metadata ?? {};
@@ -894,11 +906,16 @@ export function createAgentRunGateway({
throw error;
}
const runMessageText = extractRunMessageText(row);
const runDisplayText = extractRunDisplayText(row);
const pageDataIntent = isPageDataIntent(runMessageText)
|| routing?.suggestedSkill === 'page-data-collect';
const pageGenerationIntent = isPageGenerationIntent(runMessageText)
|| routing?.suggestedSkill === 'static-page-publish';
const requiresPageDeliverable = pageDataIntent || pageGenerationIntent;
// A bare “generate a page” request has no subject to render. The assistant's
// clarification is a successful conversational turn, not a failed delivery.
// Once the user supplies a subject, the existing fail-closed guard still applies.
const requiresPageDeliverable = pageDataIntent
|| (pageGenerationIntent && !isGenericPageGenerationRequest(runDisplayText));
let deliverables = null;
if (requiresPageDeliverable || typeof validateRunDeliverables === 'function') {
const latest = await getRunById(runId);