diff --git a/apps/web/src/session-logic.test.ts b/apps/web/src/session-logic.test.ts index adc31f483d24..23c7de5aa3f8 100644 --- a/apps/web/src/session-logic.test.ts +++ b/apps/web/src/session-logic.test.ts @@ -412,7 +412,7 @@ describe("V2 session presentation", () => { }); }); - it("files agent messages in every thread and Home watch reports in the work log, and keeps human prompts", () => { + it("files agent messages in every thread and Home watch reports in the work log, and keeps human and native subagent prompts", () => { const now = DateTime.makeUnsafe("2026-10-30T00:00:00.000Z"); const message = (threadId: ThreadId, id: string, sender?: ThreadId, text = "Merged #17.") => ({ @@ -452,6 +452,11 @@ describe("V2 session presentation", () => { message(home, "from-user"), message(ThreadId.make("worker"), "brief-from-pm", pm), message(home, "home-report:1", undefined, report), + { + ...message(ThreadId.make("subagent"), "native-subagent-prompt", pm), + createdBy: "agent" as const, + creationSource: "provider" as const, + }, ].map((item, position) => ({ position, visibility: "local" as const, @@ -461,7 +466,13 @@ describe("V2 session presentation", () => { })), optimisticMessages: [], }); - expect(entries.map((entry) => entry.kind)).toEqual(["work", "message", "work", "work"]); + expect(entries.map((entry) => entry.kind)).toEqual([ + "work", + "message", + "work", + "work", + "message", + ]); expect(entries[0]).toMatchObject({ kind: "work", entry: { itemType: "user_message", detail: "Merged #17." }, diff --git a/packages/contracts/src/home.ts b/packages/contracts/src/home.ts index 384c21250ded..c840a1eb422d 100644 --- a/packages/contracts/src/home.ts +++ b/packages/contracts/src/home.ts @@ -126,7 +126,10 @@ export const isHomeDeliveredMessage = ( message.idleCompaction === undefined && message.scheduledTaskId === undefined; -/** Durable agent provenance, including coordination results created by the server. */ +/** + * Durable agent provenance, including coordination results created by the server. A + * provider-written user message is the prompt a native subagent ran, so it stays a prompt. + */ export const isAgentDeliveredMessage = ( threadId: string, message: { @@ -142,10 +145,10 @@ export const isAgentDeliveredMessage = ( message.idleCompaction === undefined && message.scheduledTaskId === undefined && message.context?.guest === undefined && + message.creationSource !== "provider" && (message.senderThreadId !== undefined || message.coordination !== undefined || - (message.createdBy === "agent" && - (message.creationSource === "mcp" || message.creationSource === "provider")) || + (message.createdBy === "agent" && message.creationSource === "mcp") || (isHomeThreadId(threadId) && message.createdBy !== undefined && message.createdBy !== "user")); export const HomeEnableInput = Schema.Struct({ modelSelection: ModelSelection });