fix(timeline): exclude attachments from canonical prompt text

Structured provider prompts can include hidden history attachments before the user's text. Persist only plain prompt blocks so authoritative user messages match what the composer displayed while provider input remains unchanged.
This commit is contained in:
Mohamed Boudra
2026-08-01 01:55:23 +02:00
parent a1e73896c5
commit 4ade006528
2 changed files with 15 additions and 4 deletions
@@ -8183,9 +8183,20 @@ test("authoritative timeline includes provider-emitted submitted user prompt", a
workspaceId: undefined,
});
await manager.runAgent(snapshot.id, "hello from composer", {
clientMessageId: "msg-client-1",
});
await manager.runAgent(
snapshot.id,
[
{
type: "text",
mimeType: "text/plain",
contextKind: "chat_history",
title: "Chat history",
text: "<chat-history-summary>hidden fork history</chat-history-summary>",
},
{ type: "text", text: "hello from composer" },
],
{ clientMessageId: "msg-client-1" },
);
const liveEvents = events.filter(
(event): event is Extract<AgentManagerEvent, { type: "agent_stream" }> =>
@@ -95,7 +95,7 @@ function submittedPromptText(prompt: AgentPromptInput): string {
return prompt;
}
return prompt
.flatMap((block) => (block.type === "text" ? [block.text] : []))
.flatMap((block) => (block.type === "text" && !("mimeType" in block) ? [block.text] : []))
.join("\n")
.trim();
}