fix(web): accept unknown stream payload when binding spoken prompts
Independent Staging Quality Gate / validate (push) Successful in 21m40s
Independent Staging Quality Gate / publish (push) Successful in 11m12s

Publish next build failed because the spoken-bind helper required result/output
on chunk payload, which the runner stream type does not have.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-08-26 00:27:49 +08:00
co-authored by Cursor
parent 97b02aef5d
commit 9326b7d0a4
4 changed files with 28 additions and 4 deletions
@@ -48,12 +48,15 @@ export function readOpenQuestionPrompt(value: unknown): string | null {
export function openQuestionPromptFromToolResult(chunk: {
type?: string;
payload?: { result?: unknown; output?: unknown };
payload?: unknown;
object?: unknown;
}): string | null {
if (chunk.type !== "tool-result") return null;
return readOpenQuestionPrompt(chunk.payload?.result)
?? readOpenQuestionPrompt(chunk.payload?.output)
const payload = chunk.payload && typeof chunk.payload === "object" && !Array.isArray(chunk.payload)
? chunk.payload as Record<string, unknown>
: null;
return readOpenQuestionPrompt(payload?.result)
?? readOpenQuestionPrompt(payload?.output)
?? readOpenQuestionPrompt(chunk.object)
?? readOpenQuestionPrompt(chunk.payload);
}
@@ -245,6 +245,11 @@ test("usage completes or releases without hiding settlement failures", () => {
assert.match(run, /if \(!answerText\.trim\(\)\) \{[\s\S]*composeRectificationTurnNarration/);
assert.match(run, /bindSpokenToOpenQuestion/);
assert.match(run, /openQuestionPromptFromToolResult/);
const narration = readFileSync(
new URL("../src/lib/rectification-agentic/v9/turn-narration.ts", import.meta.url),
"utf8",
);
assert.match(narration, /payload\?: unknown/);
assert.doesNotMatch(run, /splitRectificationSpokenAndThinking/);
assert.match(run, /emit\(event: PublicStreamEvent\): Promise<void> \| void;/);
assert.match(run, /agentGenerationSettings\(options\.generationModel, \{[\s\S]*thinking: "enabled"/);
@@ -1371,7 +1371,7 @@ test("persisted choice prompt replaces a competing model follow-up without a top
);
assert.equal(openQuestionPromptFromToolResult({
type: "tool-result",
payload: { result: { open_question: { prompt } } },
payload: { toolName: "rectification-record-evidence-batch", result: { open_question: { prompt } } },
}), prompt);
const { options, emitted } = runOptions({