Add safe chat reasoning disclosure
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
AgentPromptInput,
|
||||
type AgentChatMessage,
|
||||
} from "./AgentChat";
|
||||
import { getToolTraceSummary } from "./agentChatModel";
|
||||
import { buildReasoningSteps, getToolTraceSummary } from "./agentChatModel";
|
||||
|
||||
const assistantMessage: AgentChatMessage = {
|
||||
id: "assistant-1",
|
||||
@@ -111,3 +111,40 @@ describe("AgentChat phase 1 components", () => {
|
||||
expect(markup).not.toContain("Werkzeuge verwendet");
|
||||
});
|
||||
});
|
||||
|
||||
describe("AgentChat phase 2 reasoning disclosure", () => {
|
||||
test("builds safe reasoning steps from tool traces without exposing raw inputs", () => {
|
||||
const steps = buildReasoningSteps(assistantMessage.toolTrace);
|
||||
|
||||
expect(steps).toEqual([
|
||||
{
|
||||
label: "summarize_transactions",
|
||||
description: "12 Umsaetze zusammengefasst",
|
||||
status: "complete",
|
||||
},
|
||||
{
|
||||
label: "list_transactions",
|
||||
description: "1 Treffer",
|
||||
status: "complete",
|
||||
},
|
||||
]);
|
||||
expect(JSON.stringify(steps)).not.toContain("Mai 2026");
|
||||
});
|
||||
|
||||
test("renders an assistant work-progress disclosure from tool traces", () => {
|
||||
const markup = renderToStaticMarkup(<AgentMessage message={assistantMessage} />);
|
||||
|
||||
expect(markup).toContain("So wurde gearbeitet");
|
||||
expect(markup).toContain("summarize_transactions");
|
||||
expect(markup).toContain("12 Umsaetze zusammengefasst");
|
||||
});
|
||||
|
||||
test("marks the current agent step as active while submitting", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<AgentConversation messages={[assistantMessage]} isSubmitting />,
|
||||
);
|
||||
|
||||
expect(markup).toContain("Antwort wird vorbereitet");
|
||||
expect(markup).toContain("data-status=\"active\"");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user