Files
Jyotisha/frontend/src/lib/rectification-agentic/v9/turn-narration.ts
T
Jesse_Chen fe87a9ecdb fix(web): isolate rectification answers from tool-step planning text
Mastra intermediate text-delta was published as answer.delta, then set-focus domain errors reset the attempt and replayed evidence. Publish only the terminal no-tool step, persist the next probe on the server, and ground batch quotes in the source turn.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-24 21:26:57 +08:00

33 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { parseAgentChoiceCopy } from "./choice-card";
import type { V9CaseDossier } from "./tool-service";
export type RectificationNarrationDto = Readonly<{
acknowledgedFacts: readonly string[];
nextQuestion: string | null;
}>;
export function publicNarrationDtoFromDossier(dossier: V9CaseDossier): RectificationNarrationDto {
const acknowledgedFacts = dossier.evidence
.filter((item) => item.status === "confirmed" || item.status === "draft" || item.status === "pending_confirmation")
.slice(-4)
.map((item) => item.summary.trim())
.filter((item) => item.length >= 2);
const choice = parseAgentChoiceCopy(dossier.conversationSummary.activeFocus?.expectedAnswerSchema ?? null);
return {
acknowledgedFacts,
nextQuestion: choice?.prompt ?? null,
};
}
export function composeRectificationTurnNarration(dto: RectificationNarrationDto): string {
const parts: string[] = [];
if (dto.acknowledgedFacts.length > 0) {
parts.push(`已经记下:${dto.acknowledgedFacts.join("")}`);
}
if (dto.nextQuestion) parts.push(dto.nextQuestion);
if (parts.length === 0) {
return "请继续说下一件你记得比较清楚、大概带年份的经历。";
}
return parts.join("");
}