diff --git a/apps/server/src/orchestration-v2/ContextHandoffBudget.test.ts b/apps/server/src/orchestration-v2/ContextHandoffBudget.test.ts index 094e95be10d55..38d061d7ba77e 100644 --- a/apps/server/src/orchestration-v2/ContextHandoffBudget.test.ts +++ b/apps/server/src/orchestration-v2/ContextHandoffBudget.test.ts @@ -1,6 +1,7 @@ import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter"; import { assert, describe, it } from "@effect/vitest"; import { + ProjectId, ContextHandoffId, NodeId, PROVIDER_SEND_TURN_MAX_ATTACHMENTS, @@ -39,6 +40,7 @@ const decodeHandoff = Schema.decodeUnknownSync(OrchestrationV2ContextHandoff); const now = DateTime.makeUnsafe("2026-09-17T00:00:00Z"); const threadId = ThreadId.make("thread:handoff"); +const summaryScope = { projectId: ProjectId.make("project:handoff"), threadId }; const providerThread: OrchestrationV2ProviderThread = { id: ProviderThreadId.make("provider-thread:target"), driver: ProviderDriverKind.make("codex"), @@ -621,6 +623,7 @@ describe("handoff delivery", () => { Effect.succeed([ { id: `summary:${"a".repeat(64)}`, + ...summaryScope, coveredItemIds, text: `Generated conversation summary with as-sent project evidence: ${"x".repeat(14_000)}`, }, @@ -705,6 +708,8 @@ describe("handoff delivery", () => { const deliver = Effect.fn("test.deliverWithSummaries")(function* ( summaries: ReadonlyArray<{ readonly id: `summary:${string}`; + readonly projectId: ProjectId; + readonly threadId: ThreadId; readonly coveredItemIds: ReadonlyArray; readonly text: string; readonly knowledgeFactIds?: ReadonlyArray; @@ -748,6 +753,7 @@ describe("handoff delivery", () => { const baseline = yield* deliver([]); const old = { id: `summary:${"a".repeat(64)}` as const, + ...summaryScope, coveredItemIds: ids(1, 8), text: `OLD ${"o".repeat(8_000)}`, knowledgeFactIds: [ProjectFactId.make("fact:old")], @@ -760,6 +766,7 @@ describe("handoff delivery", () => { ); const recent = { id: `summary:${"b".repeat(64)}` as const, + ...summaryScope, coveredItemIds: ids(16, 23), text: `RECENT ${"r".repeat(1_200)}`, knowledgeFactIds: [ProjectFactId.make("fact:recent")], @@ -781,7 +788,7 @@ describe("handoff delivery", () => { }), ); - it.effect("keeps the newest messages ahead of tool results when a summary needs room", () => + it.effect("keeps the newest messages ahead of tool results, with or without a summary", () => Effect.gen(function* () { const tool = (id: string): OrchestrationV2HistoricalMessage => ({ ...message(id, "assistant", "t".repeat(1_500)), @@ -824,6 +831,7 @@ describe("handoff delivery", () => { Effect.succeed([ { id: `summary:${"c".repeat(64)}` as const, + ...summaryScope, coveredItemIds: older.slice(1).map((entry) => entry.itemId), text: `OLDER ${"s".repeat(1_600)}`, }, @@ -839,6 +847,23 @@ describe("handoff delivery", () => { }); assert.includeMembers([...verbatim], newest, "the six newest messages"); assert.lengthOf(summarized, 19, "the summary of older history is delivered"); + + // Without a summary to offer, the tool result next to the oldest tail message gives way. + const unsummarized = yield* deliverContextHandoffs({ + handoffs: [source], + providerThread: { ...providerThread, nativeThreadRef: null }, + budget: historyCost( + [older[0]!, ...tail.filter((entry) => entry !== tail[1])], + "c".repeat(600), + ), + alreadyDeliveredItemIds: new Set(), + persist: () => Effect.void, + }); + assert.includeMembers( + unsummarized.messages.map((entry) => entry.itemId), + newest, + "the six newest messages without a summary", + ); }), ); @@ -1201,4 +1226,292 @@ describe("handoff delivery", () => { assert.equal(calls, 0); }), ); + + const summaryId = `summary:${"a".repeat(64)}` as const; + const summaryTools = "t3_conversation_summary_list and t3_conversation_summary_expand"; + + it.effect("names the summaries a delivery sent in the receipt, not in the prompt", () => + Effect.gen(function* () { + const history = Array.from({ length: 30 }, (_, index) => + message(`item:receipt-${index}`, index % 2 === 0 ? "user" : "assistant", "x".repeat(700)), + ); + const covered = history.slice(16, 24).map((entry) => entry.itemId); + const source: OrchestrationV2ContextHandoff = { + ...handoff, + id: ContextHandoffId.make("handoff:summary-receipt"), + summaryText: [ + "Coverage.", + `Some omitted items have conversation summaries; read one with ${summaryTools}.`, + ].join("\n"), + history: { messages: history, coverage: "Coverage.", omittedItems: 0 }, + }; + let durable = source; + let context = ""; + const delivery = yield* deliverContextHandoffs({ + handoffs: [source], + providerThread, + budget: 16_000, + alreadyDeliveredItemIds: new Set(), + summaries: () => + Effect.succeed([ + { + id: summaryId, + ...summaryScope, + coveredItemIds: covered, + text: `RECENT ${"r".repeat(1_200)}`, + }, + ]), + inject: (input) => { + context = input.context; + return Effect.succeed(true); + }, + persist: (value) => + Effect.sync(() => { + durable = value; + }), + }); + yield* delivery.delivered; + const line = `Replaced earlier spans with ${summaryId}; read one with ${summaryTools}.`; + assert.deepEqual(durable.delivery?.summaryIds, [summaryId]); + assert.equal(durable.summaryText, `Coverage.\n${line}`); + assert.notInclude(durable.summaryText, "RECENT"); + // The delivered summary's own header names it and how to expand it. + assert.include(context, "RECENT"); + assert.notInclude(context, "Replaced earlier spans"); + assert.notInclude(context, "Not shown here"); + }), + ); + + it.effect("points at the summary holding an omitted tool result that was not sent", () => + Effect.gen(function* () { + const omitted: OrchestrationV2HistoricalMessage = { + ...message("item:receipt-omitted", "assistant", `Command: vp test\n${"o".repeat(20_000)}`), + kind: "command_execution", + }; + const kept = message("item:receipt-kept", "user", "kept"); + const source: OrchestrationV2ContextHandoff = { + ...handoff, + id: ContextHandoffId.make("handoff:omitted-summary"), + summaryText: "Coverage.", + history: { + messages: [omitted, kept], + coverage: "Coverage.", + omittedItems: 0, + }, + }; + let durable = source; + let context = ""; + const delivery = yield* deliverContextHandoffs({ + handoffs: [source], + providerThread, + budget: 8_000, + alreadyDeliveredItemIds: new Set(), + summaries: () => + Effect.succeed([ + { + id: summaryId, + ...summaryScope, + coveredItemIds: [omitted.itemId], + text: "S".repeat(40_000), + }, + ]), + inject: (input) => { + context = input.context; + return Effect.succeed(false); + }, + persist: (value) => + Effect.sync(() => { + durable = value; + }), + }); + yield* delivery.delivered; + const line = `Some omitted items have conversation summaries; read one with ${summaryTools}.`; + assert.isUndefined(durable.delivery?.summaryIds); + assert.isAbove(delivery.uncoveredItems, 0); + assert.equal(durable.summaryText, `Coverage.\n${line}`); + assert.notInclude(durable.summaryText, summaryId); + assert.include( + context, + `Not shown here: item:receipt-omitted (command_execution: Command: vp test). ${summaryId} holds the original text; read it with t3_conversation_summary_expand({projectId:"project:handoff",threadId:"thread:handoff",summaryId:"${summaryId}"}).`, + ); + assert.notInclude(context, "SSSS"); + }), + ); + + const listCall = `t3_conversation_summary_list({projectId:"project:handoff",threadId:"thread:handoff"})`; + it.effect.each([ + { + budget: 6_000, + tailCount: 0, + grows: false, + shown: ["item:many-19", "item:many-18", "item:many-17"], + line: `17 more summaries hold omitted items; list them with ${listCall}.`, + }, + { + budget: 1_400, + tailCount: 0, + grows: false, + shown: [], + line: `Not shown here: 20 conversation summaries hold omitted items; list them with ${listCall}.`, + }, + { + budget: 16_000, + tailCount: 50, + grows: false, + shown: [], + line: `Not shown here: 20 conversation summaries hold omitted items; list them with ${listCall}.`, + }, + { + budget: 3_448, + tailCount: 50, + grows: true, + shown: [], + line: `Not shown here: 10 conversation summaries hold omitted items; list them with ${listCall}.`, + }, + ])( + "still points at unsent summaries when their lines do not all fit: $budget", + ({ budget, tailCount, grows, shown, line }) => + Effect.gen(function* () { + const indexText = (index: number) => (grows ? String(index).padStart(2, "0") : index); + const tools = Array.from({ length: grows ? 30 : 20 }, (_, index) => ({ + ...message( + `item:many-${indexText(index)}`, + "assistant", + `Command: step ${index}\n${"o".repeat(8_000)}`, + ), + kind: "command_execution" as const, + })); + const tail = + tailCount === 0 + ? [message("item:many-kept", "user", "kept")] + : Array.from({ length: tailCount }, (_, index) => + message( + `item:tail-${indexText(index)}`, + index % 2 === 0 ? "user" : "assistant", + "k".repeat(grows ? 1 : 64), + ), + ); + const idFor = (index: number) => `summary:${index.toString(16).padStart(64, "0")}`; + const source: OrchestrationV2ContextHandoff = { + ...handoff, + id: ContextHandoffId.make("handoff:many-unsent"), + summaryText: "Coverage.", + history: { + messages: [...tools, ...tail], + coverage: "Coverage.", + omittedItems: 0, + }, + }; + let injected = { + messages: [] as ReadonlyArray, + context: "", + }; + const delivery = yield* deliverContextHandoffs({ + handoffs: [source], + providerThread, + budget, + alreadyDeliveredItemIds: new Set(), + summaries: () => + Effect.succeed( + (grows ? [...tools.slice(0, 9), tail[41]!] : tools.toReversed()).map( + (tool, index) => ({ + id: idFor(grows ? index : 19 - index), + ...summaryScope, + coveredItemIds: [tool.itemId], + text: "S".repeat(40_000), + }), + ), + ), + inject: (input) => { + injected = input; + return Effect.succeed(false); + }, + persist: () => Effect.void, + }); + yield* delivery.delivered; + assert.include(injected.context, line); + assert.includeMembers( + injected.messages.map((entry) => entry.itemId), + tail.slice(-6).map((entry) => entry.itemId), + ); + for (const index of [19, 18, 17, 16]) { + const named = `${idFor(index)} holds`; + if (shown.includes(`item:many-${index}`)) assert.include(injected.context, named); + else assert.notInclude(injected.context, named); + } + assert.isAtMost(historyCost(injected.messages, injected.context), budget); + }), + ); + + it.effect( + "replaces the receipt when the same handoff is delivered again with a different summary", + () => + Effect.gen(function* () { + const history = Array.from({ length: 30 }, (_, index) => + message( + `item:redeliver-${index}`, + index % 2 === 0 ? "user" : "assistant", + "x".repeat(700), + ), + ); + const firstId = `summary:${"c".repeat(64)}` as const; + const secondId = `summary:${"d".repeat(64)}` as const; + let durable: OrchestrationV2ContextHandoff = { + ...handoff, + id: ContextHandoffId.make("handoff:redeliver"), + summaryText: "Coverage.", + history: { messages: history, coverage: "Coverage.", omittedItems: 0 }, + }; + const deliver = ( + summaryId: typeof firstId, + covered: ReadonlyArray, + nativeId: string, + ) => + Effect.gen(function* () { + const delivery = yield* deliverContextHandoffs({ + handoffs: [durable], + providerThread: { + ...providerThread, + nativeThreadRef: { + driver: ProviderDriverKind.make("codex"), + strength: "strong", + nativeId, + }, + }, + budget: 16_000, + alreadyDeliveredItemIds: new Set(), + summaries: () => + Effect.succeed([ + { + id: summaryId, + ...summaryScope, + coveredItemIds: covered, + text: `OFFER ${"r".repeat(1_200)}`, + }, + ]), + inject: () => Effect.succeed(true), + persist: (value) => + Effect.sync(() => { + durable = value; + }), + }); + yield* delivery.delivered; + }); + yield* deliver( + firstId, + history.slice(4, 12).map((entry) => entry.itemId), + "native:first", + ); + assert.deepEqual(durable.delivery?.summaryIds, [firstId]); + yield* deliver( + secondId, + history.slice(16, 24).map((entry) => entry.itemId), + "native:second", + ); + const line = `Replaced earlier spans with ${secondId}; read one with ${summaryTools}.`; + assert.equal(durable.summaryText, `Coverage.\n${line}`); + assert.deepEqual(durable.delivery?.summaryIds, [secondId]); + assert.notInclude(durable.summaryText, firstId); + }), + ); }); diff --git a/apps/server/src/orchestration-v2/ContextHandoffDelivery.ts b/apps/server/src/orchestration-v2/ContextHandoffDelivery.ts index bd4f548b6d4fa..a1f0cc428475f 100644 --- a/apps/server/src/orchestration-v2/ContextHandoffDelivery.ts +++ b/apps/server/src/orchestration-v2/ContextHandoffDelivery.ts @@ -25,6 +25,108 @@ const MESSAGE_KINDS: ReadonlySet = new Set([ "peer_reply", ]); +export function freshTailMessages( + messages: ReadonlyArray, +): ReadonlyArray { + return messages + .filter((message) => message.kind !== undefined && MESSAGE_KINDS.has(message.kind)) + .slice(-FRESH_TAIL_MESSAGES); +} + +const SUMMARY_TOOLS = "t3_conversation_summary_list and t3_conversation_summary_expand"; + +const REPLACED_SPANS_PREFIX = "Replaced earlier spans with "; +const OMITTED_SUMMARY_PREFIX = "Some omitted items have conversation summaries; read one with "; +const RECEIPT_PREFIXES = [REPLACED_SPANS_PREFIX, OMITTED_SUMMARY_PREFIX] as const; + +function handoffReceiptLine(input: { + readonly summaryIds: ReadonlyArray; + readonly omittedHaveSummaries: boolean; +}): string { + if (input.summaryIds.length > 0) { + return `${REPLACED_SPANS_PREFIX}${input.summaryIds.join(", ")}; read one with ${SUMMARY_TOOLS}.`; + } + if (input.omittedHaveSummaries) { + return `${OMITTED_SUMMARY_PREFIX}${SUMMARY_TOOLS}.`; + } + return ""; +} + +const STUBBED_ITEMS = 5; +const NOT_SHOWN_LINES = 3; + +const summaryCount = (count: number, adjective: string) => + `${count} ${adjective} ${count === 1 ? "summary holds" : "summaries hold"} omitted items`; +const listCall = (offer: HandoffSummary) => + `t3_conversation_summary_list({projectId:"${offer.projectId}",threadId:"${offer.threadId}"})`; + +/** + * Where to read omitted items held by summaries that did not fit, nearest the present first. A + * delivered summary needs no line: its header already names its expand call. Agents are not told + * their project id. Lines give way from the far end; when none fits, one line names the list call. + */ +function notShownBlock(input: { + readonly offers: ReadonlyArray; + readonly omitted: ReadonlySet; + readonly messages: ReadonlyArray; + readonly fits: (block: string) => boolean; +}) { + const lines = notShownLines(input); + if (lines.length === 0) return { text: "", fallback: "" }; + const fallback = `Not shown here: ${summaryCount(lines.length, "conversation")}; list them with ${listCall(lines[0]!.offer)}.`; + for (let shown = Math.min(lines.length, NOT_SHOWN_LINES); shown > 0; shown--) { + const rest = lines.slice(shown); + const block = [ + ...lines.slice(0, shown).map(({ line }) => line), + ...(rest.length === 0 + ? [] + : [`${summaryCount(rest.length, "more")}; list them with ${listCall(rest[0]!.offer)}.`]), + ].join("\n"); + if (input.fits(block)) return { text: block, fallback }; + } + return { text: input.fits(fallback) ? fallback : "", fallback }; +} + +function notShownLines(input: { + readonly offers: ReadonlyArray; + readonly omitted: ReadonlySet; + readonly messages: ReadonlyArray; +}): ReadonlyArray<{ readonly offer: HandoffSummary; readonly line: string }> { + const byId = new Map(input.messages.map((message) => [message.itemId, message])); + return input.offers.flatMap((offer) => { + const covered = offer.coveredItemIds.filter((id) => input.omitted.has(id)); + if (covered.length === 0) return []; + const stubs = covered + .flatMap((id) => { + const message = byId.get(id); + return message?.kind === undefined || MESSAGE_KINDS.has(message.kind) ? [] : [message]; + }) + .slice(-STUBBED_ITEMS) + .map((tool) => `${tool.itemId} (${tool.kind}: ${tool.text.split("\n", 1)[0]!.slice(0, 80)})`); + const more = covered.length - stubs.length; + const ids = offer.summaryIds ?? [offer.id]; + return [ + { + offer, + line: `Not shown here: ${[...stubs, ...(more > 0 ? [`${more} ${stubs.length > 0 ? "more " : ""}omitted item${more === 1 ? "" : "s"}`] : [])].join(", ")}. ${ids.join(", ")} ${ids.length === 1 ? "holds" : "hold"} the original text; read it with t3_conversation_summary_expand({projectId:"${offer.projectId}",threadId:"${offer.threadId}",summaryId:"${ids[0]}"})${ids.length === 1 ? "" : " and the other ids"}.`, + }, + ]; + }); +} + +function withoutHandoffReceipt(summaryText: string): string { + return summaryText + .split("\n") + .filter((line) => !RECEIPT_PREFIXES.some((prefix) => line.startsWith(prefix))) + .join("\n"); +} + +function withHandoffReceipt(summaryText: string, line: string): string { + const base = withoutHandoffReceipt(summaryText); + if (line === "") return base; + return base === "" ? line : `${base}\n${line}`; +} + /** The provider prompt for a turn that carries inline context ahead of the user's text. */ export const withInlineContext = (context: string, userText: string): string => context === "" ? userText : `${context}\n\nUser message:\n${userText}`; @@ -127,16 +229,20 @@ export const deliverContextHandoffs = Effect.fn("orchestrationV2.deliverContextH (sum, handoff) => sum + (handoff.history?.omittedItems ?? 0), 0, ); - let selected = selectHistory({ + const freshTail = new Set(freshTailMessages(messages).map((message) => message.itemId)); + let selection: Parameters[0] = { messages, coverage: fullCoverage, omittedItems: priorOmittedCount, omittedItemIds: pending.flatMap((handoff) => handoff.history?.omittedItemIds ?? []), budget, - }); + first: freshTail, + }; + let selected = selectHistory(selection); const summarized = new Set(); const chosen: Array = []; - const priorOmitted = new Set( + let offered: ReadonlyArray = []; + const priorOmitted = new Set( pending.flatMap((handoff) => handoff.history?.omittedItemIds ?? []), ); if ( @@ -146,10 +252,9 @@ export const deliverContextHandoffs = Effect.fn("orchestrationV2.deliverContextH // The newest messages stay verbatim when they fit. Tool results around them may give way // to a summary. const pinned = new Set( - messages - .filter((message) => message.kind !== undefined && MESSAGE_KINDS.has(message.kind)) - .slice(-FRESH_TAIL_MESSAGES) - .flatMap((message) => (selected.messages.includes(message) ? [message.itemId] : [])), + selected.messages.flatMap((message) => + freshTail.has(message.itemId) ? [message.itemId] : [], + ), ); const eligible = new Set( [...priorOmitted, ...messages.map((message) => message.itemId)].filter( @@ -158,7 +263,8 @@ export const deliverContextHandoffs = Effect.fn("orchestrationV2.deliverContextH ); // Most covered items per byte first, so coarse summaries of old history come before the // finer ones next to the tail. Ties keep the offered order, nearest the present first. - const offers = (yield* input.summaries(eligible)).toSorted( + offered = yield* input.summaries(eligible); + const offers = offered.toSorted( (a, b) => b.coveredItemIds.length / Buffer.byteLength(b.text) - a.coveredItemIds.length / Buffer.byteLength(a.text), @@ -169,7 +275,7 @@ export const deliverContextHandoffs = Effect.fn("orchestrationV2.deliverContextH const proposed = new Set([...summarized, ...candidate.coveredItemIds]); const summaryBlock = [...chosen, candidate].map((summary) => summary.text).join("\n\n"); const proposedIds = new Set(proposed); - const reduced = selectHistory({ + const proposedSelection = { messages: messages.filter((message) => !proposed.has(message.itemId)), coverage: `${fullCoverage}\n${proposed.size} older items are represented by the generated conversation summaries below instead of verbatim.\n${summaryBlock}`, omittedItems: @@ -179,7 +285,8 @@ export const deliverContextHandoffs = Effect.fn("orchestrationV2.deliverContextH // Otherwise a newer tool result takes the room an older pinned message needs, and // the summary is refused for a loss it did not have to cause. first: pinned, - }); + }; + const reduced = selectHistory(proposedSelection); // A summary earns its space only when more history arrives with it than without it. const kept = new Set(reduced.messages.map((message) => message.itemId)); if ( @@ -190,17 +297,42 @@ export const deliverContextHandoffs = Effect.fn("orchestrationV2.deliverContextH continue; chosen.push(candidate); for (const id of candidate.coveredItemIds) summarized.add(id); + selection = proposedSelection; selected = reduced; } } - const estimatedTokens = historyCost(selected.messages, selected.context); + const notShown = () => + notShownBlock({ + offers: offered.filter((offer) => !chosen.includes(offer)), + omitted: new Set( + [...priorOmitted, ...selected.omittedItemIds].filter((id) => !summarized.has(id)), + ), + messages, + fits: (block) => historyCost(selected.messages, `${selected.context}\n${block}`) <= budget, + }); + let pointer = notShown(); + let reserved = 0; + while (pointer.text === "" && pointer.fallback !== "") { + const reserve = + historyCost(selected.messages, `${selected.context}\n${pointer.fallback}`) - + historyCost(selected.messages, selected.context); + if (reserve <= reserved) break; + const reduced = selectHistory({ ...selection, budget: budget - reserve }); + const kept = new Set(reduced.messages.map((message) => message.itemId)); + // Older optional history yields to recovery instructions; the fresh tail stays pinned. + if ( + selected.messages.some( + (message) => freshTail.has(message.itemId) && !kept.has(message.itemId), + ) + ) + break; + reserved = reserve; + selected = reduced; + pointer = notShown(); + } const summaryFactIds = [ ...new Set(chosen.flatMap((summary) => summary.knowledgeFactIds ?? [])), ]; - if (estimatedTokens > budget) { - if (input.deferInline) return empty; - return yield* new ContextHandoffBudgetError(); - } const omittedItemIds = new Set(selected.omittedItemIds); // Items that arrive neither verbatim nor beneath a delivered summary. An older record may // count omitted items without naming them, or carry only text that did not fit: both count, @@ -232,12 +364,36 @@ export const deliverContextHandoffs = Effect.fn("orchestrationV2.deliverContextH summarizedItemIds, }; }; + const stillOmitted = (handoff: OrchestrationV2ContextHandoff) => + new Set([ + ...(handoff.history?.omittedItemIds ?? []).filter((id) => !summarized.has(id)), + ...(handoff.history?.messages ?? []) + .filter((message) => omittedItemIds.has(message.itemId)) + .map((message) => message.itemId), + ]); + const omittedHaveSummaries = (ids: ReadonlySet) => + offered.some((offer) => offer.coveredItemIds.some((id) => ids.has(id))); + const receiptFor = (handoff: OrchestrationV2ContextHandoff) => + withHandoffReceipt( + handoff.summaryText, + handoffReceiptLine({ + summaryIds: summaryDelivery(handoff).summaryIds ?? [], + omittedHaveSummaries: omittedHaveSummaries(stillOmitted(handoff)), + }), + ); + const context = pointer.text === "" ? selected.context : `${selected.context}\n${pointer.text}`; + const estimatedTokens = historyCost(selected.messages, context); + if (estimatedTokens > budget) { + if (input.deferInline) return empty; + return yield* new ContextHandoffBudgetError(); + } const persist = (status: "pending" | "injected" | "inline") => Effect.forEach( pending, (handoff, index) => input.persist({ ...handoff, + summaryText: receiptFor(handoff), ...(nativeThreadId === undefined ? {} : { @@ -245,14 +401,7 @@ export const deliverContextHandoffs = Effect.fn("orchestrationV2.deliverContextH nativeThreadId, status, estimatedTokens: index === 0 ? estimatedTokens : 0, - omittedItemIds: [ - ...(handoff.history?.omittedItemIds ?? []).filter( - (id) => !summarized.has(id), - ), - ...(handoff.history?.messages ?? []) - .filter((message) => omittedItemIds.has(message.itemId)) - .map((message) => message.itemId), - ], + omittedItemIds: [...stillOmitted(handoff)], ...summaryDelivery(handoff), itemIds: selected.messages .filter((message) => @@ -279,7 +428,7 @@ export const deliverContextHandoffs = Effect.fn("orchestrationV2.deliverContextH yield* persist("pending"); const injected = yield* input.inject({ messages: selected.messages, - context: selected.context, + context, }); if (injected) { yield* persist("injected"); @@ -303,7 +452,7 @@ export const deliverContextHandoffs = Effect.fn("orchestrationV2.deliverContextH } return { uncoveredItems, - context: renderHistory(selected.messages, selected.context), + context: renderHistory(selected.messages, context), messages: selected.messages, summaryFactIds, delivered: persist("inline").pipe( diff --git a/apps/server/src/orchestration-v2/ContextHandoffService.test.ts b/apps/server/src/orchestration-v2/ContextHandoffService.test.ts index f86a21e2f7891..ddfe66cc879fb 100644 --- a/apps/server/src/orchestration-v2/ContextHandoffService.test.ts +++ b/apps/server/src/orchestration-v2/ContextHandoffService.test.ts @@ -2,6 +2,7 @@ import { assert, it } from "@effect/vitest"; import { ContextTransferId, MessageId, + NodeId, OrchestrationV2ContextHandoffJson, ProjectId, ProviderDriverKind, @@ -21,7 +22,10 @@ import * as Schema from "effect/Schema"; import * as ContextHandoffService from "./ContextHandoffService.ts"; import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator"; -import { historyCost } from "@t3tools/provider-core/server/handoffBudget"; +import { + historyCost, + REPLACEMENT_HANDOFF_TOKEN_CAP, +} from "@t3tools/provider-core/server/handoffBudget"; import { deliverContextHandoffs } from "./ContextHandoffDelivery.ts"; import { ProjectionStoreThreadNotFoundError } from "./ProjectionStore.ts"; @@ -296,6 +300,84 @@ it.layer(layerTest)("ContextHandoffService provider handoff", (it) => { assert.lengthOf(delivered.match(/TOOL_EVIDENCE_SENTINEL/g) ?? [], 1); }), ); + + it.effect( + "keeps the six newest messages when a large subagent result fits the replacement budget", + () => + Effect.gen(function* () { + const service = yield* ContextHandoffService.ContextHandoffServiceV2; + const now = DateTime.makeUnsafe("2026-01-01T00:00:00.000Z"); + const threadId = ThreadId.make("thread:fresh-tail"); + const base = { + threadId, + runId: null, + nodeId: null, + providerThreadId: null, + providerTurnId: null, + nativeItemRef: null, + parentItemId: null, + status: "completed" as const, + title: null, + startedAt: now, + completedAt: now, + updatedAt: now, + }; + const say = ( + id: string, + role: "user" | "assistant", + text: string, + ordinal: number, + ): OrchestrationV2TurnItem => importedItem({ role, id, text, ordinal }); + const crowded = ["FRESH_4", "FRESH_5", "FRESH_6"].map((marker, index) => + say( + marker, + index % 2 === 0 ? "user" : "assistant", + `${marker}\n${"m".repeat(18_000)}`, + index + 1, + ), + ); + const subagent = { + ...base, + id: TurnItemId.make("item:large-subagent"), + ordinal: 4, + type: "subagent" as const, + subagentId: NodeId.make("node:large-subagent"), + origin: "app_owned" as const, + driver: ProviderDriverKind.make("codex"), + providerInstanceId: ProviderInstanceId.make("codex"), + childThreadId: null, + prompt: "Investigate the failure", + result: `SUBAGENT_RESULT\n${"s".repeat(45_000)}`, + } satisfies OrchestrationV2TurnItem; + const recent = ["FRESH_1", "FRESH_2", "FRESH_3"].map((marker, index) => + say(marker, index % 2 === 0 ? "assistant" : "user", marker, index + 5), + ); + const handoff = yield* service.prepareProviderHandoff({ + threadId, + targetRunId: RunId.make("run:fresh-tail"), + transferId: null, + fromProviderThreadIds: [], + toProviderThreadId: ProviderThreadId.make("provider-thread:fresh-tail"), + fromProviderInstanceId: ProviderInstanceId.make("codex"), + toProviderInstanceId: ProviderInstanceId.make("codex"), + coveredRunOrdinals: { from: 1, to: 1 }, + strategy: "full_thread_summary", + tokenCap: REPLACEMENT_HANDOFF_TOKEN_CAP, + items: [say("opening", "user", "OPENING", 0), ...crowded, subagent, ...recent], + createdAt: now, + }); + const kept = handoff.history?.messages.map((message) => message.text).join("\n") ?? ""; + for (const marker of ["FRESH_1", "FRESH_2", "FRESH_3", "FRESH_4", "FRESH_5", "FRESH_6"]) { + assert.include(kept, marker, "the six newest messages stay in the handoff"); + } + assert.notInclude(kept, "SUBAGENT_RESULT"); + assert.include(handoff.history?.omittedItemIds ?? [], subagent.id); + assert.isAtMost( + historyCost(handoff.history?.messages ?? [], handoff.summaryText), + REPLACEMENT_HANDOFF_TOKEN_CAP, + ); + }), + ); }); it.effect("caps the side chat context block without summarizing discarded parent history", () => diff --git a/apps/server/src/orchestration-v2/ContextHandoffService.ts b/apps/server/src/orchestration-v2/ContextHandoffService.ts index 29ef038ca4303..5cf414e0c3933 100644 --- a/apps/server/src/orchestration-v2/ContextHandoffService.ts +++ b/apps/server/src/orchestration-v2/ContextHandoffService.ts @@ -24,6 +24,7 @@ import { } from "@t3tools/provider-core/server/handoffBudget"; import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator"; import { createOrchestrationV2TurnItemVisibility } from "@t3tools/shared/orchestrationV2Timeline"; +import { freshTailMessages } from "./ContextHandoffDelivery.ts"; import type { ProjectionStoreV2Shape } from "./ProjectionStore.ts"; export class ContextHandoffPrepareError extends Schema.TaggedError()( @@ -547,20 +548,24 @@ const makeContextHandoffService = Effect.fn("orchestrationV2.ContextHandoffServi ...input, threadId: input.sourceThreadId ?? input.threadId, }); + const messages = input.items.flatMap((item) => { + const message = historicalMessage(item); + return message === null + ? [] + : [ + { + ...message, + ...(item.runId === null ? {} : { runStatus: runStatuses.get(item.runId) }), + }, + ]; + }); const selected = selectHistory({ - messages: input.items.flatMap((item) => { - const message = historicalMessage(item); - return message === null - ? [] - : [ - { - ...message, - ...(item.runId === null ? {} : { runStatus: runStatuses.get(item.runId) }), - }, - ]; - }), + messages, coverage, budget: input.tokenCap ?? tokenCap, + ...(input.strategy === "full_thread_summary" + ? { first: new Set(freshTailMessages(messages).map((message) => message.itemId)) } + : {}), }); return { id: handoffId, diff --git a/apps/server/src/orchestration-v2/ProjectionStore.test.ts b/apps/server/src/orchestration-v2/ProjectionStore.test.ts index 74dd498c3dc49..ba6d485a13893 100644 --- a/apps/server/src/orchestration-v2/ProjectionStore.test.ts +++ b/apps/server/src/orchestration-v2/ProjectionStore.test.ts @@ -3632,6 +3632,90 @@ it.effect("SQL snapshot windows leave handoff bodies in SQLite without changing }).pipe(Effect.provide(layerTest)), ); +it.effect("a redelivered handoff rewrites the receipt on its earlier run's activity item", () => + Effect.gen(function* () { + const store = yield* ProjectionStore.ProjectionStoreV2; + const sql = yield* SqlClient.SqlClient; + const now = yield* DateTime.now; + const threadId = ThreadId.make("thread:handoff-receipt"); + const runId = RunId.make("run:handoff-receipt"); + const providerThreadId = ProviderThreadId.make("provider-thread:handoff-receipt"); + const handoff = { + id: ContextHandoffId.make("handoff:handoff-receipt"), + transferId: null, + threadId, + targetRunId: runId, + fromProviderThreadIds: [providerThreadId], + toProviderThreadId: providerThreadId, + coveredRunOrdinals: { from: 1, to: 1 }, + strategy: "full_thread_summary" as const, + status: "ready" as const, + summaryMessageId: null, + summaryText: "Coverage.", + createdByProviderInstanceId: providerInstanceId, + createdAt: now, + updatedAt: now, + }; + const item = (id: string, contextHandoffId: ContextHandoffId) => ({ + id: TurnItemId.make(id), + threadId, + runId, + nodeId: null, + providerThreadId, + providerTurnId: null, + nativeItemRef: null, + parentItemId: null, + ordinal: 1, + status: "completed" as const, + title: null, + startedAt: now, + completedAt: now, + updatedAt: now, + type: "handoff" as const, + contextHandoffId, + fromProviderThreadIds: [providerThreadId], + toProviderThreadId: providerThreadId, + fromProviderInstanceIds: [providerInstanceId], + toProviderInstanceId: providerInstanceId, + strategy: "full_thread_summary" as const, + summary: "Coverage.", + }); + for (const payload of [ + item("item:handoff-receipt:shown", handoff.id), + item("item:handoff-receipt:other", ContextHandoffId.make("handoff:other")), + ]) { + yield* store.apply({ + id: EventId.make(`event:${payload.id}`), + type: "turn-item.updated", + threadId, + runId, + occurredAt: now, + payload, + }); + } + yield* store.apply({ + id: EventId.make("event:handoff-receipt:redelivered"), + type: "context-handoff.updated", + threadId, + runId: RunId.make("run:handoff-receipt:later"), + occurredAt: now, + payload: { ...handoff, summaryText: "Coverage.\nReplaced earlier spans with summary:a." }, + }); + const rows = yield* sql<{ id: string; summary: string }>` + SELECT turn_item_id AS id, json_extract(payload_json, '$.summary') AS summary + FROM orchestration_v2_projection_turn_items WHERE thread_id = ${threadId} + ORDER BY turn_item_id + `; + assert.deepEqual(rows, [ + { id: "item:handoff-receipt:other", summary: "Coverage." }, + { + id: "item:handoff-receipt:shown", + summary: "Coverage.\nReplaced earlier spans with summary:a.", + }, + ]); + }).pipe(Effect.provide(layerTest)), +); + it.effect("lists only active subagent IDs without loading shell data", () => Effect.gen(function* () { const store = yield* ProjectionStore.ProjectionStoreV2; diff --git a/apps/server/src/orchestration-v2/ProjectionStore.ts b/apps/server/src/orchestration-v2/ProjectionStore.ts index 2303b5adf30cf..0d8ce0412f6d2 100644 --- a/apps/server/src/orchestration-v2/ProjectionStore.ts +++ b/apps/server/src/orchestration-v2/ProjectionStore.ts @@ -100,6 +100,7 @@ import * as Schema from "effect/Schema"; import * as SqlClient from "effect/sql/SqlClient"; import type * as Statement from "effect/sql/Statement"; +import { turnStartHistoryTypes } from "@t3tools/provider-core/server/conversationEvidence"; import { MCP_APP_OUTPUT_KEY } from "@t3tools/shared/mcpApp"; import { threadHtmlRenderAttachmentIds } from "../attachmentStore.ts"; import { readableSearchText } from "./messageSearchIndex.ts"; @@ -1149,11 +1150,23 @@ export function applyToProjection( }; case "checkpoint.rollback-requested": return base; - case "context-handoff.updated": - return { + case "context-handoff.updated": { + const handoff = event.payload; + const contextHandoffs = upsertById(base.contextHandoffs, handoff); + const stale = (item: OrchestrationV2TurnItem) => + item.type === "handoff" && + item.runId === handoff.targetRunId && + item.contextHandoffId === handoff.id && + item.summary !== handoff.summaryText; + if (!base.turnItems.some(stale)) return { ...base, contextHandoffs }; + return withLocalVisibleTurnItems({ ...base, - contextHandoffs: upsertById(base.contextHandoffs, event.payload), - }; + contextHandoffs, + turnItems: base.turnItems.map((item) => + stale(item) ? { ...item, summary: handoff.summaryText } : item, + ), + }); + } case "context-transfer.created": case "context-transfer.updated": return { @@ -3213,6 +3226,15 @@ export const layer: Layer.Layer = status = excluded.status, updated_at = excluded.updated_at, payload_json = excluded.payload_json + `; + // The activity item shows the receipt, and a redelivery rewrites it from a later run. + yield* sql` + UPDATE orchestration_v2_projection_turn_items + SET payload_json = json_set(payload_json, '$.summary', ${event.payload.summaryText}) + WHERE run_id = ${event.payload.targetRunId} + AND type = 'handoff' + AND json_extract(payload_json, '$.contextHandoffId') = ${event.payload.id} + AND json_extract(payload_json, '$.summary') IS NOT ${event.payload.summaryText} `; break; } @@ -5365,8 +5387,7 @@ export const layer: Layer.Layer = const rows = yield* sql` SELECT payload_json FROM orchestration_v2_projection_turn_items WHERE thread_id = ${threadId} - AND type IN ('user_message','assistant_message','command_execution','error', - 'run_interrupt_result','file_change','proposed_plan') + AND type IN ${sql.in(turnStartHistoryTypes)} AND ${runIds === undefined ? sql`1` : sql`run_id IN ${sql.in(runIds)}`} ORDER BY ordinal ASC, turn_item_id ASC `; diff --git a/apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts b/apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts index bdff8aef406c9..c0b70055cab67 100644 --- a/apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts +++ b/apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts @@ -4606,3 +4606,139 @@ effectIt.effect("declares no replayed runs to the summary lookup on a provider s expect(lookups).toEqual([undefined]); }), ); + +effectIt.effect("copies the delivered summary receipt onto the handoff activity item", () => + Effect.gen(function* () { + const harness = makeLocalCommandHarness({ + text: "Return to this provider", + previousTurn: { runStatus: "completed", turnStatus: "completed" }, + }); + const projection = harness.projection(); + const targetRun = projection.runs.at(-1)!; + const sourceRunId = RunId.make("peer-run"); + const interruptedRunId = RunId.make("interrupted-run"); + const peerThreadId = ProviderThreadId.make("peer-thread"); + const now = targetRun.requestedAt; + const summaryId = `summary:${"c".repeat(64)}`; + const messages: Array = Array.from( + { length: 30 }, + (_, index) => ({ + itemId: TurnItemId.make(`receipt-item-${index}`), + role: index % 2 === 0 ? "user" : "assistant", + text: "x".repeat(700), + threadId: projection.thread.id, + runId: sourceRunId, + providerThreadId: peerThreadId, + status: "completed", + kind: index % 2 === 0 ? "user_message" : "assistant_message", + }), + ); + const handoff: OrchestrationV2ContextHandoff = { + id: ContextHandoffId.make("receipt-handoff"), + transferId: null, + threadId: projection.thread.id, + targetRunId: interruptedRunId, + fromProviderThreadIds: [peerThreadId], + toProviderThreadId: targetRun.providerThreadId!, + coveredRunOrdinals: { from: 2, to: 2 }, + strategy: "delta_since_target_last_seen", + status: "ready", + summaryMessageId: null, + summaryText: "Coverage.", + history: { messages, coverage: "Coverage.", omittedItems: 0, omittedItemIds: [] }, + createdByProviderInstanceId: null, + createdAt: now, + updatedAt: now, + }; + const activity = { + id: TurnItemId.make("receipt-activity"), + threadId: projection.thread.id, + runId: interruptedRunId, + nodeId: targetRun.rootNodeId, + providerThreadId: targetRun.providerThreadId, + providerTurnId: null, + nativeItemRef: null, + parentItemId: null, + ordinal: 1, + status: "completed" as const, + title: "Provider handoff", + startedAt: now, + completedAt: now, + updatedAt: now, + type: "handoff" as const, + contextHandoffId: handoff.id, + fromProviderThreadIds: [peerThreadId], + toProviderThreadId: targetRun.providerThreadId!, + fromProviderInstanceIds: [harness.oldInstanceId], + toProviderInstanceId: targetRun.providerInstanceId, + strategy: handoff.strategy, + summary: "Coverage.", + }; + harness.setProjection({ + ...projection, + runs: [ + projection.runs[0]!, + { + ...projection.runs[0]!, + id: sourceRunId, + ordinal: 2, + providerThreadId: peerThreadId, + providerInstanceId: harness.oldInstanceId, + }, + { ...targetRun, id: interruptedRunId, ordinal: 3, status: "interrupted" }, + { ...targetRun, ordinal: 4 }, + ], + contextHandoffs: [handoff], + turnItems: [activity], + }); + // The handoff was first shown in an interrupted run; turn start reads only its own run's items. + const read = harness.getTurnStartContext.getMockImplementation()!; + harness.getTurnStartContext.mockImplementation(() => + read().pipe( + Effect.map((context) => ({ + ...context, + turnItems: context.turnItems.filter((item) => item.runId === targetRun.id), + })), + ), + ); + yield* harness.start.pipe( + Effect.provideService(ConversationSummaryRuntime, { + hasPendingPass: () => Effect.succeed(false), + summarizeThread: () => Effect.succeed({ hasMore: false }), + forHandoff: () => + Effect.succeed([ + { + id: summaryId, + projectId: projection.thread.projectId, + threadId: projection.thread.id, + coveredItemIds: messages.slice(16, 24).map((entry) => entry.itemId), + text: `RECENT ${"r".repeat(1_200)}`, + }, + ]), + }), + ); + const start = harness.startRootRun.mock.calls.at(-1)![0]; + yield* start.session.startTurn({ + appThread: start.appThread, + threadId: start.appThread.id, + runId: start.run.id, + runOrdinal: start.run.ordinal, + providerTurnOrdinal: start.providerTurnOrdinal, + attemptId: start.attemptId, + rootNodeId: start.rootNode.id, + providerThread: start.providerThread, + message: start.message, + modelSelection: start.modelSelection, + runtimePolicy: start.runtimePolicy, + }); + const line = `Replaced earlier spans with ${summaryId}; read one with t3_conversation_summary_list and t3_conversation_summary_expand.`; + const stored = harness.projection().contextHandoffs[0]; + const shown = harness.projection().turnItems.find((item) => item.type === "handoff"); + expect(stored?.summaryText).toBe(`Coverage.\n${line}`); + expect(stored?.summaryText).not.toContain("RECENT"); + expect(shown && shown.type === "handoff" ? shown.summary : undefined).toBe(stored?.summaryText); + const sent = harness.nativeStart.mock.calls.at(-1)?.[0].message.text; + expect(sent).toContain("RECENT"); + expect(sent).not.toContain(line); + }), +); diff --git a/apps/server/src/orchestration-v2/ProviderTurnStartService.ts b/apps/server/src/orchestration-v2/ProviderTurnStartService.ts index 292b25ae91400..e8b6634a8f8f9 100644 --- a/apps/server/src/orchestration-v2/ProviderTurnStartService.ts +++ b/apps/server/src/orchestration-v2/ProviderTurnStartService.ts @@ -1049,8 +1049,7 @@ export const layer: Layer.Layer< projectId: projection.thread.projectId, handoffs, itemIds, - // A recovery replays every earlier run of this thread onto a fresh native - // conversation, but reads its history without MCP tool results. + // A summary may cite a source this handoff did not carry, for runs the caller names. ...(replaysEarlierRuns && run.ordinal > 1 ? { replayed: { threadId: projection.thread.id, from: 1, to: run.ordinal - 1 } } : {}), diff --git a/apps/server/src/orchestration-v2/TurnStartReads.test.ts b/apps/server/src/orchestration-v2/TurnStartReads.test.ts index 343718dc34cb5..6018327fe97fe 100644 --- a/apps/server/src/orchestration-v2/TurnStartReads.test.ts +++ b/apps/server/src/orchestration-v2/TurnStartReads.test.ts @@ -14,6 +14,7 @@ import { TurnItemId, type OrchestrationV2AppThread, type OrchestrationV2Run, + type OrchestrationV2TurnItem, } from "@t3tools/contracts"; import * as DateTime from "effect/DateTime"; import * as Effect from "effect/Effect"; @@ -610,3 +611,144 @@ it.effect( assert.isTrue((yield* store.getTurnStartContext(forkId, forkRunId)).hasConversation); }).pipe(Effect.provide(layerDatabase)), ); + +it.effect( + "loads finalized dynamic tool, search, and subagent results into turn-start history", + () => + Effect.gen(function* () { + const store = yield* ProjectionStore.ProjectionStoreV2; + const now = yield* DateTime.now; + const threadId = ThreadId.make("thread:tool-history"); + const runId = RunId.make("run:tool-history"); + const instanceId = ProviderInstanceId.make("codex"); + yield* store.apply({ + id: EventId.make("event:tool-history:thread"), + type: "thread.created", + threadId, + occurredAt: now, + payload: { + id: threadId, + projectId: ProjectId.make("project:tool-history"), + title: "Tool history", + providerInstanceId: instanceId, + modelSelection: { instanceId, model: "test" }, + runtimeMode: "full-access", + interactionMode: "default", + branch: null, + worktreePath: null, + activeProviderThreadId: null, + lineage: { parentThreadId: null, relationshipToParent: null, rootThreadId: threadId }, + forkedFrom: null, + createdBy: "user", + creationSource: "web", + createdAt: now, + updatedAt: now, + archivedAt: null, + settledOverride: null, + settledAt: null, + lastVisitedAt: null, + deletedAt: null, + }, + }); + yield* store.apply({ + id: EventId.make("event:tool-history:run"), + type: "run.updated", + threadId, + runId, + occurredAt: now, + payload: { + id: runId, + threadId, + ordinal: 1, + providerInstanceId: instanceId, + modelSelection: { instanceId, model: "test" }, + providerThreadId: null, + userMessageId: MessageId.make("message:tool-history"), + rootNodeId: null, + activeAttemptId: null, + status: "completed", + requestedAt: now, + startedAt: now, + completedAt: now, + checkpointId: null, + contextHandoffId: null, + }, + }); + const base = { + threadId, + runId, + nodeId: null, + providerThreadId: null, + providerTurnId: null, + nativeItemRef: null, + parentItemId: null, + status: "completed" as const, + title: null, + startedAt: now, + completedAt: now, + updatedAt: now, + }; + const evidence = [ + { + ...base, + id: TurnItemId.make("item:dynamic-tool"), + ordinal: 1, + type: "dynamic_tool" as const, + toolName: "verify_health", + input: { endpoint: "/health" }, + output: { failure: "Expected HTTP 200, received 503" }, + }, + { + ...base, + id: TurnItemId.make("item:file-search"), + ordinal: 2, + type: "file_search" as const, + pattern: "health", + results: [{ fileName: "src/health.ts", line: 7, preview: "export const health = 200" }], + }, + { + ...base, + id: TurnItemId.make("item:web-search"), + ordinal: 3, + type: "web_search" as const, + patterns: ["HTTP 503"], + results: [{ url: "https://example.com/status/503", title: "Service unavailable" }], + }, + { + ...base, + id: TurnItemId.make("item:subagent"), + ordinal: 4, + type: "subagent" as const, + subagentId: NodeId.make("node:health-check"), + origin: "app_owned" as const, + driver: ProviderDriverKind.make("codex"), + providerInstanceId: instanceId, + childThreadId: null, + prompt: "Check the health endpoint", + result: "The upstream service is unavailable", + }, + ] satisfies ReadonlyArray; + const reasoning = { + ...base, + id: TurnItemId.make("item:reasoning"), + ordinal: 5, + type: "reasoning" as const, + text: "private reasoning", + streaming: false, + } satisfies OrchestrationV2TurnItem; + for (const item of [...evidence, reasoning]) { + yield* store.apply({ + id: EventId.make(`event:${item.id}`), + type: "turn-item.updated", + threadId, + runId, + occurredAt: now, + payload: item, + }); + } + assert.deepEqual( + (yield* store.getTurnStartHistory(threadId)).map((item) => item.id), + evidence.map((item) => item.id), + ); + }).pipe(Effect.provide(layerDatabase)), +); diff --git a/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts b/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts index fbfb009659db5..8ebfe6cf157df 100644 --- a/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts +++ b/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts @@ -5284,6 +5284,8 @@ describe("orchestration v2 context restart", () => { : [ { id: ConversationSummaryId.make(`summary:${"a".repeat(64)}`), + projectId: ProjectId.make("project:summary"), + threadId: ThreadId.make("thread:summary"), text: summaryText, // The first offered item is the oldest one that does not arrive verbatim. coveredItemIds: [...itemIds].slice(gap ? 1 : 0).map((id) => TurnItemId.make(id)), diff --git a/apps/server/src/project/conversationSummaries/ConversationSummaries.ts b/apps/server/src/project/conversationSummaries/ConversationSummaries.ts index 9143dce1eef99..302ec41461472 100644 --- a/apps/server/src/project/conversationSummaries/ConversationSummaries.ts +++ b/apps/server/src/project/conversationSummaries/ConversationSummaries.ts @@ -149,6 +149,17 @@ const renderStatements = (summary: Pick, +) => { + const condensed = summary.sources.some((source) => source.kind === "summary"); + return [ + `[Conversation summary ${summary.id}: written by a model from ${summary.sources.length} earlier ${condensed ? "summaries" : "source ranges"} of thread ${summary.threadId}. It is a summary, not the original evidence.]`, + `Read the exact source ranges with t3_conversation_summary_expand({projectId:"${summary.projectId}",threadId:"${summary.threadId}",summaryId:"${summary.id}"}); #n is the nth source.${condensed ? " A source that is a summary expands the same way, down to the original text." : ""} Follow nextOffset and nextTextOffset together to retrieve all text.`, + ...renderStatements(summary), + ].join("\n"); +}; + /** Keep statements in order while the rendered roll-up fits its byte budget. */ const fitCondensed = ( sources: ReadonlyArray, @@ -1152,15 +1163,6 @@ const make = Effect.gen(function* () { ), ); - const renderForHandoff = (summary: ConversationSummary) => { - const condensed = summary.sources.some((source) => source.kind === "summary"); - return [ - `[Conversation summary ${summary.id}: written by a model from ${summary.sources.length} earlier ${condensed ? "summaries" : "source ranges"} of thread ${summary.threadId}. It is a summary, not the original evidence.]`, - `Read the exact source ranges with t3_conversation_summary_expand({projectId:"${summary.projectId}",threadId:"${summary.threadId}",summaryId:"${summary.id}"}); #n is the nth source.${condensed ? " A source that is a summary expands the same way, down to the original text." : ""} Follow nextOffset and nextTextOffset together to retrieve all text.`, - ...renderStatements(summary), - ].join("\n"); - }; - const coveredUncarriedSources = Effect.fn("ConversationSummaries.coveredUncarriedSources")( function* ( threadId: ThreadId, @@ -1303,9 +1305,11 @@ const make = Effect.gen(function* () { if (nodes.length !== group.nodes.length) continue; offered.push({ id: nodes[0]!.id, + projectId: nodes[0]!.projectId, + threadId: nodes[0]!.threadId, ...(nodes.length > 1 ? { summaryIds: nodes.map((summary) => summary.id) } : {}), text: [ - ...nodes.map(renderForHandoff), + ...nodes.map(renderSummaryForHandoff), ...sourceItems.flatMap((item) => { const attached = evidence?.textByItem.get(item.itemId); return attached === undefined diff --git a/apps/server/src/project/conversationSummaries/conversationSummarySchedule.ts b/apps/server/src/project/conversationSummaries/conversationSummarySchedule.ts index e359db0620d4a..0de3584bf7d01 100644 --- a/apps/server/src/project/conversationSummaries/conversationSummarySchedule.ts +++ b/apps/server/src/project/conversationSummaries/conversationSummarySchedule.ts @@ -59,6 +59,8 @@ export class ConversationSummaryPassError extends Schema.TaggedError; /** Labelled as a generated summary, with the ids needed to expand its sources. */ readonly text: string; diff --git a/docs/internals/context-handoffs.md b/docs/internals/context-handoffs.md index 1e8f4fe85d034..1abf4994c241e 100644 --- a/docs/internals/context-handoffs.md +++ b/docs/internals/context-handoffs.md @@ -9,16 +9,20 @@ accepting one only when more history items arrive with it than without it, count summarized items alike. The six newest messages are never traded away, which matches the tail the summary pass never covers. A summary's sources must all be carried by the handoffs, with one exception that only the caller can declare. A recovery replays every earlier run -of its thread onto a fresh native conversation but reads history without MCP tool results, so the -caller names those runs and a summary may cite history inside them. Nothing is inferred from a -handoff record: it does not name the thread its run ordinals describe, and a fork's history spans -its ancestors. These transfers do not +of its thread onto a fresh native conversation and carries tool results verbatim when they fit. +The caller may still name those runs so a summary can cite a source the handoff did not carry. +Nothing is inferred from a handoff record: it does not name the thread its run ordinals +describe, and a fork's history spans its ancestors. These transfers do not reconstruct native provider session state, tool state, approvals, or attachments. Within a provider handoff payload, selected evidence is stored in `history.messages`. The `summaryText` field carries a compact coverage and recovery receipt, which also appears in the handoff activity item. It does not repeat the selected message or tool-output bodies. Delivery reads the intact evidence from `history`, preserving the same selection and context budget. +The receipt names the summaries a delivery used, for people; the prompt does not repeat it, because +a delivered summary's own header carries its expand call. The prompt adds a line only for a summary +that did not fit but holds omitted items, with the full expand call, since agents are not told their +project id. The `context-handoffs` mcp-tool-use eval measures both choices. Fork merge-back and side-chat fallback text use `compactText` for compact item descriptions. Its 240-character prefix is a property of those fallback descriptions, not the provider handoff history diff --git a/evals/mcp-tool-use/README.md b/evals/mcp-tool-use/README.md index 7943f6f9d580d..f92e3b1cfa7d0 100644 --- a/evals/mcp-tool-use/README.md +++ b/evals/mcp-tool-use/README.md @@ -14,6 +14,7 @@ pnpm mcp-tool-use --model claude-opus-5-5 --out runs/opus - `ANTHROPIC_API_KEY` in the repo root `.env` pays for Claude models and the Haiku shell simulator. - Codex models (`gpt-*` in `MODELS` in `run.ts`) go through a CLIProxyAPI server, set up as the `vibeproxy` model provider in `~/.codex/config.toml`. Keep the proxy under about 12 samples in flight across all runs. +- `--model morph-kimik31 --shell-model morph-dsv41flash` runs both through Morph's Anthropic-compatible API with `MORPH_API_KEY`, else the `morph` provider in OpenCode's config, and never reads an Anthropic key. Morph limits uncached input tokens per minute, so pass `--concurrency 1`. - `--shell-model` picks the model that plays the shell: `claude-haiku-5-5` by default, or `gpt-6.1-terra` / `gpt-6-luna` through the same proxy, so Codex runs need no Anthropic key. Prefer Terra: Luna often contradicts the case's world (it calls named checkouts missing or files empty). Compare runs only when they used the same shell model. - Flags: `--case `, `--cases `, `--samples ` (default 2, and a 3rd when the first 2 disagree), `--concurrency ` (samples in flight, default 8), `--max-steps `, `--effort `, `--dry-run` (prints request bodies, no model calls), and `--context` (prints the size of T3's text and schemas, no key needed). - `--baseline --stop-on-regression` stops as soon as a case that passed every baseline sample fails. Use it to test one copy change against a baseline run. @@ -28,6 +29,7 @@ Cases are JSON lines in `cases/`, one file per area. The case schema in `run.ts` - `experience`: the real mistake, in a sentence. `source`: where it happened. - `setup`: the fake thread, its `world` (repo, branch, files, PRs, pages), `priorTurns`, and `mocks` for tool results. With `world.backgroundTasks`, `t3_background_wait` answers from T3's own handler and ThreadManagementService, so its result and errors are the checkout's; a prior wait with `"result": "default"` gets that result too. - `setup.mocks` keys are tool names. A key of the form `tool?arg=value` answers only calls whose `arg` equals `value`, so one case can return a different result per summary id; the bare tool name answers the rest. +- `setup.contextHandoff`: the first turn after a context restart. T3's own preparation and delivery code builds the history it puts ahead of `prompt` from the case's items, the older item ids preparation dropped, and summaries that fit or do not (`contextHandoff.ts`). - `setup.priorTurns[].toolCalls[].resultFile`: load a repository-relative file as the tool result instead of copying its contents into the case. An empty `prompt` resumes a top-level thread after its last prior tool result without adding a user message. Side-chat and subagent setups require a nonempty prompt. - `expect`: the checks, such as `calls`, `callsMustNot`, `maxCalls`, `order`, `shellMust`, `textMust`, `finalTextMust` (the last text, once the turn ended), and `linked`. A call's `args` match partially: `~text` is a case-insensitive substring, `"<=N"` / `">=N"` bound a number, `null` matches a missing key, and keys may be dotted paths. Device cases also use `device` to check every child brief, forbid raw UI commands, bound failed device actions per user turn, and require artifact paths in completed final answers. Secrets cases use `secret` (see [Secrets cases](#secrets-cases)). diff --git a/evals/mcp-tool-use/cases/context-handoffs.ndjson b/evals/mcp-tool-use/cases/context-handoffs.ndjson new file mode 100644 index 0000000000000..9781529972208 --- /dev/null +++ b/evals/mcp-tool-use/cases/context-handoffs.ndjson @@ -0,0 +1,3 @@ +{"id": "handoff-undelivered-summary-finds-tool-output", "area": "context-handoffs", "kind": "bad", "pattern": "an omitted tool result is findable after a context restart", "experience": "After a context restart, the failing test run was among older items the handoff only counted, and nothing said which summary held it, so the agent could not quote its output.", "privacy": "commit-safe", "setup": {"role": "top", "contextHandoff": {"projectId": "project-app", "threadId": "thread-checkout", "budget": 16000, "items": [{"id": "item-94b331d6", "type": "command_execution", "input": "vp test src/orders", "output": " FAIL src/orders/orders.migration.test.ts > backfills settle state\nAssertionError: expected 'pending' to be 'settled' // Object.is equality\n \u276f src/orders/orders.migration.test.ts:88:31\n\n Test Files 1 failed | 41 passed (42)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n", "exitCode": 1}, {"id": "item-a1bdf983", "type": "user_message", "text": "Ship the orders migration first, then the banner."}, {"id": "item-f2171f2f", "type": "assistant_message", "text": "The orders migration is merged and the suite is green."}, {"id": "item-4e1195df", "type": "user_message", "text": "Now add the checkout banner."}, {"id": "item-f55ff16f", "type": "assistant_message", "text": "Added the banner in src/checkout/CheckoutBanner.tsx."}, {"id": "item-2c3a4249", "type": "user_message", "text": "Make it dismissible."}, {"id": "item-f46dd28a", "type": "assistant_message", "text": "Done. Dismissal persists in localStorage under checkout-banner-dismissed."}, {"id": "item-4539e4b4", "type": "user_message", "text": "Run lint too."}, {"id": "item-66220e71", "type": "assistant_message", "text": "Lint is clean."}], "omittedItemIds": ["item-2e4c6f56", "item-872737ae", "item-893a3cfd", "item-3638b187", "item-cf7e8619", "item-ce84b712", "item-00ff21aa", "item-1bb94136", "item-c5351329", "item-ef5c50e3", "item-effbfe9f", "item-44b4c059", "item-ebcadf84", "item-1b4935ae", "item-be426a01", "item-d44d78ce", "item-933e9917", "item-468024b8", "item-2c91afca", "item-0c2edc68", "item-9b747028", "item-83738b4d", "item-7d8f50f3", "item-8e185163", "item-e355a8ba", "item-c1469eec", "item-f2ba7de4", "item-b5074040", "item-c250b0ec"], "summaries": [{"id": "summary:e8bc163c82eee18733288c7d4ac636db3a6deb013ef2d37b68322be20edc45cc", "coveredItemIds": ["item-2e4c6f56", "item-872737ae", "item-893a3cfd", "item-3638b187", "item-cf7e8619", "item-ce84b712", "item-00ff21aa", "item-1bb94136", "item-94b331d6", "item-c5351329", "item-ef5c50e3", "item-effbfe9f", "item-44b4c059", "item-ebcadf84", "item-1b4935ae", "item-be426a01", "item-d44d78ce", "item-933e9917", "item-468024b8", "item-2c91afca", "item-0c2edc68", "item-9b747028", "item-83738b4d", "item-7d8f50f3"], "statements": [{"text": "Ran the orders migration tests; the settle-state backfill test failed.", "cites": ["item-94b331d6"]}, {"text": "The backfill was fixed afterwards by settling orders whose payment captured.", "cites": ["item-44b4c059"]}], "fits": false}]}, "mocks": {"t3_project_list": {"projects": [{"id": "project-app", "title": "app", "workspaceRoot": "/home/user/app", "defaultModelSelection": null, "scripts": []}]}, "t3_thread_read": {"threadId": "thread-checkout", "view": "activity", "items": [{"itemId": "item-2e4c6f56", "type": "user_message", "text": "Start the orders migration: backfill settle state for old orders."}, {"itemId": "item-872737ae", "type": "assistant_message", "text": "Plan: add a settle_state column, backfill it, then update the checkout reads."}], "nextPosition": null}, "t3_conversation_summary_list": {"enabled": true, "lastPass": null, "summaries": [{"id": "summary:e8bc163c82eee18733288c7d4ac636db3a6deb013ef2d37b68322be20edc45cc", "projectId": "project-app", "threadId": "thread-checkout", "sources": [{"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-2e4c6f56", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-872737ae", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-893a3cfd", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-3638b187", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-cf7e8619", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ce84b712", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-00ff21aa", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-1bb94136", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-94b331d6", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-c5351329", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ef5c50e3", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-effbfe9f", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-44b4c059", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ebcadf84", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-1b4935ae", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-be426a01", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-d44d78ce", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-933e9917", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-468024b8", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-2c91afca", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-0c2edc68", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-9b747028", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-83738b4d", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-7d8f50f3", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}], "statements": [{"text": "Ran the orders migration tests; the settle-state backfill test failed.", "citations": ["turn_item:item-94b331d6"]}, {"text": "The backfill was fixed afterwards by settling orders whose payment captured.", "citations": ["turn_item:item-44b4c059"]}], "modelSelection": {"instanceId": "codex", "model": "gpt-5"}, "createdAt": "2026-11-15T08:30:00.000Z"}], "nextCursor": null}, "t3_conversation_summary_describe": {"state": "available", "summary": {"id": "summary:e8bc163c82eee18733288c7d4ac636db3a6deb013ef2d37b68322be20edc45cc", "projectId": "project-app", "threadId": "thread-checkout", "sources": [{"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-2e4c6f56", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-872737ae", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-893a3cfd", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-3638b187", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-cf7e8619", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ce84b712", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-00ff21aa", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-1bb94136", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-94b331d6", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-c5351329", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ef5c50e3", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-effbfe9f", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-44b4c059", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ebcadf84", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-1b4935ae", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-be426a01", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-d44d78ce", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-933e9917", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-468024b8", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-2c91afca", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-0c2edc68", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-9b747028", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-83738b4d", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-7d8f50f3", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}], "statements": [{"text": "Ran the orders migration tests; the settle-state backfill test failed.", "citations": ["turn_item:item-94b331d6"]}, {"text": "The backfill was fixed afterwards by settling orders whose payment captured.", "citations": ["turn_item:item-44b4c059"]}], "modelSelection": {"instanceId": "codex", "model": "gpt-5"}, "createdAt": "2026-11-15T08:30:00.000Z"}}, "t3_conversation_summary_expand": {"state": "available", "summary": {"id": "summary:e8bc163c82eee18733288c7d4ac636db3a6deb013ef2d37b68322be20edc45cc", "projectId": "project-app", "threadId": "thread-checkout", "sources": [{"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-2e4c6f56", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-872737ae", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-893a3cfd", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-3638b187", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-cf7e8619", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ce84b712", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-00ff21aa", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-1bb94136", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-94b331d6", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-c5351329", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ef5c50e3", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-effbfe9f", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-44b4c059", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ebcadf84", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-1b4935ae", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-be426a01", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-d44d78ce", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-933e9917", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-468024b8", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-2c91afca", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-0c2edc68", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-9b747028", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-83738b4d", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-7d8f50f3", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}], "statements": [{"text": "Ran the orders migration tests; the settle-state backfill test failed.", "citations": ["turn_item:item-94b331d6"]}, {"text": "The backfill was fixed afterwards by settling orders whose payment captured.", "citations": ["turn_item:item-44b4c059"]}], "modelSelection": {"instanceId": "codex", "model": "gpt-5"}, "createdAt": "2026-11-15T08:30:00.000Z"}, "sources": [{"ref": {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-94b331d6", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, "result": {"state": "available", "source": {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-94b331d6", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, "text": "Command: vp test src/orders\nExit code: 1\n FAIL src/orders/orders.migration.test.ts > backfills settle state\nAssertionError: expected 'pending' to be 'settled' // Object.is equality\n \u276f src/orders/orders.migration.test.ts:88:31\n\n Test Files 1 failed | 41 passed (42)", "title": "vp test src/orders", "role": "tool", "createdAt": "2026-11-15T08:10:00.000Z", "archived": false}}], "nextOffset": null, "nextTextOffset": null}}}, "prompt": "Before the restart a migration test failed. What exact assertion message did it print? Quote it.", "expect": {"calls": [{"tool": "t3_conversation_summary_expand", "args": {"summaryId": "summary:e8bc163c82eee18733288c7d4ac636db3a6deb013ef2d37b68322be20edc45cc"}}], "finalTextMust": ["expected 'pending' to be 'settled'"]}, "source": {"kind": "pull-request-review", "pr": "ScriptedAlchemy/t3code#130", "finding": "Omitted tool items leave no trace of where their output went."}} +{"id": "handoff-delivered-summary-finds-tool-output", "area": "context-handoffs", "kind": "guard", "pattern": "an omitted tool result is findable after a context restart", "experience": "After a context restart, a delivered summary replaced the failing test run; the agent must read the original output instead of paraphrasing the summary.", "privacy": "commit-safe", "setup": {"role": "top", "contextHandoff": {"projectId": "project-app", "threadId": "thread-checkout", "budget": 6000, "items": [{"id": "item-ffbfd12e", "type": "user_message", "text": "Backfill settle state for old orders. Context: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}, {"id": "item-0647cb7b", "type": "assistant_message", "text": "Added the settle_state column and the backfill. yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"}, {"id": "item-d0f631ca", "type": "command_execution", "input": "vp test src/orders", "output": " FAIL src/orders/orders.migration.test.ts > backfills settle state\nAssertionError: expected 'pending' to be 'settled' // Object.is equality\n ❯ src/orders/orders.migration.test.ts:88:31\n\n Test Files 1 failed | 41 passed (42)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n at runTest (node_modules/vitest/dist/runner.js:412:9)\n", "exitCode": 1}, {"id": "item-f48069a8", "type": "assistant_message", "text": "Fixing the backfill. zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"}, {"id": "item-db5ed334", "type": "assistant_message", "text": "Backfill fixed; the orders suite passes now. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"}, {"id": "item-c02c0b96", "type": "user_message", "text": "Now add the checkout banner."}, {"id": "item-7dc96f77", "type": "assistant_message", "text": "Added the banner in src/checkout/CheckoutBanner.tsx."}, {"id": "item-4814d920", "type": "user_message", "text": "Make it dismissible."}, {"id": "item-76a82773", "type": "assistant_message", "text": "Done. Dismissal persists in localStorage under checkout-banner-dismissed."}, {"id": "item-486bacc5", "type": "user_message", "text": "Run lint too."}, {"id": "item-3c566197", "type": "assistant_message", "text": "Lint is clean."}], "summaries": [{"id": "summary:ad328846aa18b32a335816374511cac1063c704b8c57999e51da9f908290a7a4", "coveredItemIds": ["item-ffbfd12e", "item-0647cb7b", "item-d0f631ca", "item-f48069a8", "item-db5ed334"], "statements": [{"text": "The user asked to backfill settle state for old orders.", "cites": ["item-ffbfd12e"]}, {"text": "vp test src/orders failed in the settle-state backfill test.", "cites": ["item-d0f631ca"]}, {"text": "The fix settles orders whose payment captured; the suite then passed.", "cites": ["item-db5ed334"]}], "fits": true}]}, "mocks": {"t3_project_list": {"projects": [{"id": "project-app", "title": "app", "workspaceRoot": "/home/user/app", "defaultModelSelection": null, "scripts": []}]}, "t3_thread_read": {"threadId": "thread-checkout", "view": "activity", "items": [{"itemId": "item-2e4c6f56", "type": "user_message", "text": "Start the orders migration: backfill settle state for old orders."}, {"itemId": "item-872737ae", "type": "assistant_message", "text": "Plan: add a settle_state column, backfill it, then update the checkout reads."}], "nextPosition": null}, "t3_conversation_summary_expand": {"state": "available", "summary": {"id": "summary:ad328846aa18b32a335816374511cac1063c704b8c57999e51da9f908290a7a4", "projectId": "project-app", "threadId": "thread-checkout", "sources": [{"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ffbfd12e", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-0647cb7b", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-d0f631ca", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-f48069a8", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-db5ed334", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}], "statements": [{"text": "The user asked to backfill settle state for old orders.", "citations": ["turn_item:item-ffbfd12e"]}, {"text": "vp test src/orders failed in the settle-state backfill test.", "citations": ["turn_item:item-d0f631ca"]}, {"text": "The fix settles orders whose payment captured; the suite then passed.", "citations": ["turn_item:item-db5ed334"]}], "modelSelection": {"instanceId": "codex", "model": "gpt-5"}, "createdAt": "2026-11-15T08:30:00.000Z"}, "sources": [{"ref": {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-d0f631ca", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, "result": {"state": "available", "source": {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-d0f631ca", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, "text": "Command: vp test src/orders\nExit code: 1\n FAIL src/orders/orders.migration.test.ts > backfills settle state\nAssertionError: expected 'pending' to be 'settled' // Object.is equality\n ❯ src/orders/orders.migration.test.ts:88:31\n\n Test Files 1 failed | 41 passed (42)", "title": "vp test src/orders", "role": "tool", "createdAt": "2026-11-15T08:10:00.000Z", "archived": false}}], "nextOffset": null, "nextTextOffset": null}}}, "prompt": "Before the restart a migration test failed. What exact assertion message did it print? Quote it.", "expect": {"calls": [{"tool": "t3_conversation_summary_expand", "args": {"summaryId": "summary:ad328846aa18b32a335816374511cac1063c704b8c57999e51da9f908290a7a4"}}], "finalTextMust": ["expected 'pending' to be 'settled'"]}, "source": {"kind": "pull-request-review", "pr": "ScriptedAlchemy/t3code#130", "finding": "The receipt line repeats what a delivered summary already says."}} +{"id": "handoff-answers-from-verbatim-tail", "area": "context-handoffs", "kind": "control", "pattern": "an omitted tool result is findable after a context restart", "experience": "After a context restart, a question the verbatim history answers needs no summary or thread reads.", "privacy": "commit-safe", "setup": {"role": "top", "contextHandoff": {"projectId": "project-app", "threadId": "thread-checkout", "budget": 16000, "items": [{"id": "item-a1bdf983", "type": "user_message", "text": "Ship the orders migration first, then the banner."}, {"id": "item-f2171f2f", "type": "assistant_message", "text": "The orders migration is merged and the suite is green."}, {"id": "item-4e1195df", "type": "user_message", "text": "Now add the checkout banner."}, {"id": "item-f55ff16f", "type": "assistant_message", "text": "Added the banner in src/checkout/CheckoutBanner.tsx."}, {"id": "item-2c3a4249", "type": "user_message", "text": "Make it dismissible."}, {"id": "item-f46dd28a", "type": "assistant_message", "text": "Done. Dismissal persists in localStorage under checkout-banner-dismissed."}, {"id": "item-4539e4b4", "type": "user_message", "text": "Run lint too."}, {"id": "item-66220e71", "type": "assistant_message", "text": "Lint is clean."}], "omittedItemIds": ["item-2e4c6f56", "item-872737ae", "item-893a3cfd", "item-3638b187", "item-cf7e8619", "item-ce84b712", "item-00ff21aa", "item-1bb94136", "item-94b331d6", "item-c5351329", "item-ef5c50e3", "item-effbfe9f", "item-44b4c059", "item-ebcadf84", "item-1b4935ae", "item-be426a01", "item-d44d78ce", "item-933e9917", "item-468024b8", "item-2c91afca", "item-0c2edc68", "item-9b747028", "item-83738b4d", "item-7d8f50f3", "item-8e185163", "item-e355a8ba", "item-c1469eec", "item-f2ba7de4", "item-b5074040", "item-c250b0ec"], "summaries": [{"id": "summary:e8bc163c82eee18733288c7d4ac636db3a6deb013ef2d37b68322be20edc45cc", "coveredItemIds": ["item-2e4c6f56", "item-872737ae", "item-893a3cfd", "item-3638b187", "item-cf7e8619", "item-ce84b712", "item-00ff21aa", "item-1bb94136", "item-94b331d6", "item-c5351329", "item-ef5c50e3", "item-effbfe9f", "item-44b4c059", "item-ebcadf84", "item-1b4935ae", "item-be426a01", "item-d44d78ce", "item-933e9917", "item-468024b8", "item-2c91afca", "item-0c2edc68", "item-9b747028", "item-83738b4d", "item-7d8f50f3"], "statements": [{"text": "Ran the orders migration tests; the settle-state backfill test failed.", "cites": ["item-94b331d6"]}, {"text": "The backfill was fixed afterwards by settling orders whose payment captured.", "cites": ["item-44b4c059"]}], "fits": false}]}, "mocks": {"t3_project_list": {"projects": [{"id": "project-app", "title": "app", "workspaceRoot": "/home/user/app", "defaultModelSelection": null, "scripts": []}]}, "t3_thread_read": {"threadId": "thread-checkout", "view": "activity", "items": [{"itemId": "item-2e4c6f56", "type": "user_message", "text": "Start the orders migration: backfill settle state for old orders."}, {"itemId": "item-872737ae", "type": "assistant_message", "text": "Plan: add a settle_state column, backfill it, then update the checkout reads."}], "nextPosition": null}, "t3_conversation_summary_list": {"enabled": true, "lastPass": null, "summaries": [{"id": "summary:e8bc163c82eee18733288c7d4ac636db3a6deb013ef2d37b68322be20edc45cc", "projectId": "project-app", "threadId": "thread-checkout", "sources": [{"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-2e4c6f56", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-872737ae", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-893a3cfd", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-3638b187", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-cf7e8619", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ce84b712", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-00ff21aa", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-1bb94136", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-94b331d6", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-c5351329", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ef5c50e3", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-effbfe9f", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-44b4c059", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ebcadf84", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-1b4935ae", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-be426a01", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-d44d78ce", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-933e9917", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-468024b8", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-2c91afca", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-0c2edc68", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-9b747028", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-83738b4d", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-7d8f50f3", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}], "statements": [{"text": "Ran the orders migration tests; the settle-state backfill test failed.", "citations": ["turn_item:item-94b331d6"]}, {"text": "The backfill was fixed afterwards by settling orders whose payment captured.", "citations": ["turn_item:item-44b4c059"]}], "modelSelection": {"instanceId": "codex", "model": "gpt-5"}, "createdAt": "2026-11-15T08:30:00.000Z"}], "nextCursor": null}, "t3_conversation_summary_describe": {"state": "available", "summary": {"id": "summary:e8bc163c82eee18733288c7d4ac636db3a6deb013ef2d37b68322be20edc45cc", "projectId": "project-app", "threadId": "thread-checkout", "sources": [{"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-2e4c6f56", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-872737ae", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-893a3cfd", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-3638b187", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-cf7e8619", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ce84b712", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-00ff21aa", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-1bb94136", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-94b331d6", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-c5351329", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ef5c50e3", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-effbfe9f", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-44b4c059", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ebcadf84", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-1b4935ae", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-be426a01", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-d44d78ce", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-933e9917", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-468024b8", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-2c91afca", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-0c2edc68", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-9b747028", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-83738b4d", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-7d8f50f3", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}], "statements": [{"text": "Ran the orders migration tests; the settle-state backfill test failed.", "citations": ["turn_item:item-94b331d6"]}, {"text": "The backfill was fixed afterwards by settling orders whose payment captured.", "citations": ["turn_item:item-44b4c059"]}], "modelSelection": {"instanceId": "codex", "model": "gpt-5"}, "createdAt": "2026-11-15T08:30:00.000Z"}}, "t3_conversation_summary_expand": {"state": "available", "summary": {"id": "summary:e8bc163c82eee18733288c7d4ac636db3a6deb013ef2d37b68322be20edc45cc", "projectId": "project-app", "threadId": "thread-checkout", "sources": [{"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-2e4c6f56", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-872737ae", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-893a3cfd", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-3638b187", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-cf7e8619", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ce84b712", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-00ff21aa", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-1bb94136", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-94b331d6", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-c5351329", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ef5c50e3", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-effbfe9f", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-44b4c059", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-ebcadf84", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-1b4935ae", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-be426a01", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-d44d78ce", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-933e9917", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-468024b8", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-2c91afca", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-0c2edc68", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-9b747028", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-83738b4d", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-7d8f50f3", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}], "statements": [{"text": "Ran the orders migration tests; the settle-state backfill test failed.", "citations": ["turn_item:item-94b331d6"]}, {"text": "The backfill was fixed afterwards by settling orders whose payment captured.", "citations": ["turn_item:item-44b4c059"]}], "modelSelection": {"instanceId": "codex", "model": "gpt-5"}, "createdAt": "2026-11-15T08:30:00.000Z"}, "sources": [{"ref": {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-94b331d6", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, "result": {"state": "available", "source": {"kind": "turn_item", "threadId": "thread-checkout", "itemId": "item-94b331d6", "digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, "text": "Command: vp test src/orders\nExit code: 1\n FAIL src/orders/orders.migration.test.ts > backfills settle state\nAssertionError: expected 'pending' to be 'settled' // Object.is equality\n ❯ src/orders/orders.migration.test.ts:88:31\n\n Test Files 1 failed | 41 passed (42)", "title": "vp test src/orders", "role": "tool", "createdAt": "2026-11-15T08:10:00.000Z", "archived": false}}], "nextOffset": null, "nextTextOffset": null}}}, "prompt": "Which file did you put the checkout banner in?", "expect": {"notCalls": ["t3_conversation_summary_expand", "t3_conversation_summary_list", "t3_conversation_summary_describe", "t3_thread_read"], "finalTextMust": ["CheckoutBanner\\.tsx"]}, "source": {"kind": "pull-request-review", "pr": "ScriptedAlchemy/t3code#130", "finding": "Control for the not-shown lines."}} diff --git a/evals/mcp-tool-use/contextHandoff.ts b/evals/mcp-tool-use/contextHandoff.ts new file mode 100644 index 0000000000000..4f2090955a655 --- /dev/null +++ b/evals/mcp-tool-use/contextHandoff.ts @@ -0,0 +1,196 @@ +/** + * The inline history a context restart delivers, built by T3's own preparation and delivery code + * from a case's fake thread. Only the thread and its summaries are the case's. + */ +import { + ContextHandoffId, + ConversationSummaryId, + MessageId, + type OrchestrationV2ContextHandoff, + type OrchestrationV2TurnItem, + ProjectId, + ProviderDriverKind, + ProviderInstanceId, + ProviderThreadId, + RunId, + ThreadId, + TurnItemId, +} from "@t3tools/contracts"; +import { handoffCoverage, historicalMessage } from "@t3tools/provider-core/server/handoffBudget"; +import * as DateTime from "effect/DateTime"; +import * as Effect from "effect/Effect"; +import * as Schema from "effect/Schema"; + +import { deliverContextHandoffs } from "../../apps/server/src/orchestration-v2/ContextHandoffDelivery.ts"; +import { renderSummaryForHandoff } from "../../apps/server/src/project/conversationSummaries/ConversationSummaries.ts"; + +const Item = Schema.Union([ + Schema.Struct({ + id: Schema.String, + type: Schema.Literals(["user_message", "assistant_message"]), + text: Schema.String, + }), + Schema.Struct({ + id: Schema.String, + type: Schema.Literal("command_execution"), + input: Schema.String, + output: Schema.String, + exitCode: Schema.Int, + }), +]); + +/** A restarted thread: its carried items, the older ones preparation dropped, and summaries. */ +export const ContextHandoffFixture = Schema.Struct({ + projectId: Schema.String, + threadId: Schema.String, + /** Delivery budget in estimated tokens. */ + budget: Schema.Number, + items: Schema.Array(Item), + /** Older items preparation left out, oldest first: delivery knows only their ids. */ + omittedItemIds: Schema.optional(Schema.Array(Schema.String)), + summaries: Schema.Array( + Schema.Struct({ + id: Schema.String, + coveredItemIds: Schema.Array(Schema.String), + /** Each statement cites covered item ids. */ + statements: Schema.Array( + Schema.Struct({ text: Schema.String, cites: Schema.Array(Schema.String) }), + ), + /** false: too large to send beside the history, so delivery only knows it exists. */ + fits: Schema.Boolean, + }), + ), +}); +export type ContextHandoffFixture = typeof ContextHandoffFixture.Type; + +const at = DateTime.makeUnsafe("2026-11-15T09:00:00.000Z"); +const digest = "a".repeat(64); + +const turnItem = ( + fixture: ContextHandoffFixture, + item: typeof Item.Type, + ordinal: number, +): OrchestrationV2TurnItem => { + const base = { + id: TurnItemId.make(item.id), + threadId: ThreadId.make(fixture.threadId), + runId: RunId.make("run-before-restart"), + nodeId: null, + providerThreadId: null, + providerTurnId: null, + nativeItemRef: null, + parentItemId: null, + ordinal, + status: "completed" as const, + title: null, + startedAt: at, + completedAt: at, + updatedAt: at, + }; + switch (item.type) { + case "user_message": + return { + ...base, + type: item.type, + messageId: MessageId.make(`message-${item.id}`), + createdBy: "user", + creationSource: "server", + inputIntent: "turn_start", + text: item.text, + attachments: [], + }; + case "assistant_message": + return { + ...base, + type: item.type, + messageId: MessageId.make(`message-${item.id}`), + text: item.text, + streaming: false, + }; + case "command_execution": + return { ...base, ...item, id: base.id }; + } +}; + +/** The context T3 puts ahead of the user's text on the restarted conversation's first turn. */ +export const contextHandoffPrompt = (fixture: ContextHandoffFixture): string => { + const threadId = ThreadId.make(fixture.threadId); + const projectId = ProjectId.make(fixture.projectId); + const items = fixture.items.map((item, index) => turnItem(fixture, item, index + 1)); + const messages = items.flatMap((item) => historicalMessage(item) ?? []); + const handoff: OrchestrationV2ContextHandoff = { + id: ContextHandoffId.make("handoff-restart"), + transferId: null, + threadId, + targetRunId: RunId.make("run-after-restart"), + fromProviderThreadIds: [], + toProviderThreadId: ProviderThreadId.make("provider-thread-fresh"), + coveredRunOrdinals: { from: 1, to: 4 }, + strategy: "full_thread_summary", + status: "ready", + summaryMessageId: null, + summaryText: "", + history: { + messages, + coverage: handoffCoverage({ threadId, coveredRunOrdinals: { from: 1, to: 4 }, items }), + omittedItems: fixture.omittedItemIds?.length ?? 0, + omittedItemIds: (fixture.omittedItemIds ?? []).map((id) => TurnItemId.make(id)), + }, + createdByProviderInstanceId: null, + createdAt: at, + updatedAt: at, + }; + const summaries = fixture.summaries.map((summary) => { + const id = ConversationSummaryId.make(summary.id); + const text = renderSummaryForHandoff({ + id, + projectId, + threadId, + sources: summary.coveredItemIds.map((itemId) => ({ + kind: "turn_item" as const, + threadId, + itemId: TurnItemId.make(itemId), + digest, + })), + statements: summary.statements.map((statement) => ({ + text: statement.text, + citations: statement.cites.map((itemId) => `turn_item:${itemId}`), + })), + }); + return { + id, + projectId, + threadId, + // An offer that cannot fit is never shown, so its padding never reaches the model. + text: summary.fits ? text : `${text}\n${" ".repeat(fixture.budget * 8)}`, + coveredItemIds: summary.coveredItemIds.map((itemId) => TurnItemId.make(itemId)), + }; + }); + const delivery = Effect.runSync( + deliverContextHandoffs({ + handoffs: [handoff], + providerThread: { + id: handoff.toProviderThreadId, + driver: ProviderDriverKind.make("claudeAgent"), + providerInstanceId: ProviderInstanceId.make("claudeAgent"), + providerSessionId: null, + appThreadId: threadId, + ownerNodeId: null, + nativeThreadRef: null, + nativeConversationHeadRef: null, + status: "idle", + firstRunOrdinal: null, + lastRunOrdinal: null, + handoffIds: [], + forkedFrom: null, + createdAt: at, + updatedAt: at, + }, + budget: fixture.budget, + alreadyDeliveredItemIds: new Set(), + persist: () => Effect.void, + summaries: () => Effect.succeed(summaries), + }), + ); + return delivery.context; +}; diff --git a/evals/mcp-tool-use/run.ts b/evals/mcp-tool-use/run.ts index a9eb4d6ba228e..4dc36974f16d2 100644 --- a/evals/mcp-tool-use/run.ts +++ b/evals/mcp-tool-use/run.ts @@ -80,7 +80,7 @@ import { CLAUDE_PROVIDER, makeClaudeQueryOptions, } from "../../apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts"; -import { proxyConfig } from "../shared/proxy.ts"; +import { morphConfig, proxyConfig } from "../shared/proxy.ts"; import { changeRequestsCreatedBy } from "../../apps/server/src/orchestration-v2/PullRequestSyncReactor.ts"; import { decideGitHubArguments, @@ -96,6 +96,7 @@ import { NATIVE_COMPUTER_USE_TOOL, } from "./native-computer-use.ts"; import { type BackgroundWait, makeBackgroundWait } from "./backgroundWait.ts"; +import { ContextHandoffFixture, contextHandoffPrompt } from "./contextHandoff.ts"; import { DeviceExpect, gradeDevice } from "./device-grading.ts"; import { FileLinksExpect, gradeFileLinks } from "./file-link-grading.ts"; import { @@ -121,6 +122,7 @@ const MODELS = { "claude-opus-5-5": "Opus 5.5", "gpt-6.1-sol": "GPT-6.1 Sol", "gpt-6-astra": "GPT-6 Astra", + "morph-kimik31": "Kimi K3.1", } as const; type Model = keyof typeof MODELS; /** GPT models replay a Codex capture through CLIProxyAPI, the rest a Claude Code capture. */ @@ -136,7 +138,14 @@ const PRICES = { type PricedModel = keyof typeof PRICES; /** GPT models that can play the shell through CLIProxyAPI, when no Anthropic key is at hand. */ const PROXY_SHELL_MODELS = ["gpt-6-luna", "gpt-6.1-terra"] as const; -type ShellModel = PricedModel | (typeof PROXY_SHELL_MODELS)[number]; +/** Morph models replay the Claude Code capture through Morph's Anthropic-compatible API. */ +const MORPH_SHELL_MODELS = ["morph-dsv41flash"] as const; +const isMorph = (model: M): model is Extract => + model.startsWith("morph-"); +type ShellModel = + | PricedModel + | (typeof PROXY_SHELL_MODELS)[number] + | (typeof MORPH_SHELL_MODELS)[number]; const isPricedModel = (model: ShellModel): model is PricedModel => model in PRICES; const T3_PREFIX = "mcp__t3-code__"; const RUNTIME_MARKER = ""; @@ -357,6 +366,8 @@ export const McpToolUseCase = Schema.Struct({ shellMocks: Schema.optional( Schema.Array(Schema.Struct({ match: Schema.String, output: Schema.String })), ), + /** The first turn after a context restart: T3 puts the delivered history ahead of `prompt`. */ + contextHandoff: Schema.optional(ContextHandoffFixture), /** The thread is a side chat's first turn: T3 puts the parent's digest ahead of `prompt`. */ sideChat: Schema.optional( Schema.Struct({ parentThreadId: Schema.String, digest: Schema.Array(Schema.String) }), @@ -1159,8 +1170,11 @@ export const buildMessages = (sample: Sample) => { testCase.promptContext === undefined ? testCase.prompt : projectComposerContextForProvider({ text: testCase.prompt, ...testCase.promptContext }); + const handoff = testCase.setup.contextHandoff; + const inlineContext = + sideChatContext ?? (handoff === undefined ? undefined : contextHandoffPrompt(handoff)); const prompt = - sideChatContext === undefined ? userText : withInlineContext(sideChatContext, userText); + inlineContext === undefined ? userText : withInlineContext(inlineContext, userText); const childPrompt = () => taskPrompt({ task: prompt, role: delegateRole }); if (testCase.prompt !== "") push("user", text(role === "delegated-child" ? childPrompt() : prompt)); @@ -1713,9 +1727,10 @@ const simulate = Effect.fn("evaluateMcpToolUse.simulate")(function* ( : undefined; if (output === undefined) { const body = shellRequest(sample, call, config.shellModel); - const response = isPricedModel(config.shellModel) - ? yield* callModel(config.apiKey, body, config.apiKey ? undefined : config.proxy) - : yield* callCodex(config, shellResponsesRequest(body)); + const response = + isPricedModel(config.shellModel) || isMorph(config.shellModel) + ? yield* callModel(config.apiKey, body, config.apiKey ? undefined : config.proxy) + : yield* callCodex(config, shellResponsesRequest(body)); addUsage(sample.shellUsage, response.usage); output = shellOutput(response.content); } @@ -2326,7 +2341,11 @@ const runSample = Effect.fn("evaluateMcpToolUse.runSample")(function* ( for (let step = 0; step < maxSteps; step++) { const response = input ? yield* callCodex(config, codexRequest(base, input)) - : yield* callModel(config.apiKey, requestBody(sample, config.effort, messages)); + : yield* callModel( + config.apiKey, + requestBody(sample, config.effort, messages), + isMorph(config.model) ? config.proxy : undefined, + ); addUsage(usage, response.usage); if ("raw" in response) { input?.push(...response.raw); @@ -2481,7 +2500,7 @@ export const summarize = ( const codex = isCodex(options.model); const agent = spend( rows.map((row) => row.usage), - codex ? undefined : options.model, + codex || isMorph(options.model) ? undefined : options.model, ); const shell = spend( rows.map((row) => row.shellUsage), @@ -2521,8 +2540,10 @@ export const summarize = ( ...(errors.length > 0 ? [errorNote] : []), codex ? "- Cost: the agent is not priced. `vibeproxy` in `~/.codex/config.toml` may use a subscription or bill an API key per token; agent tokens are below." - : `- Estimated cost $${cost.toFixed(2)}, $${(cost / rows.length).toFixed(3)} per sample.`, - `- Agent tokens: ${agent.tokens}${codex ? "." : ` ($${agent.cost.toFixed(2)}).`}`, + : isMorph(options.model) + ? "- Cost: Morph runs are not priced; agent tokens are below." + : `- Estimated cost $${cost.toFixed(2)}, $${(cost / rows.length).toFixed(3)} per sample.`, + `- Agent tokens: ${agent.tokens}${codex || isMorph(options.model) ? "." : ` ($${agent.cost.toFixed(2)}).`}`, `- Shell simulator (${options.shellModel}) tokens: ${shell.tokens} (API-price estimate $${shell.cost.toFixed(2)}).`, ...(codex ? [ @@ -2556,6 +2577,7 @@ const Flags = Schema.Struct({ "shell-model": Schema.Literals([ ...(Object.keys(PRICES) as Array), ...PROXY_SHELL_MODELS, + ...MORPH_SHELL_MODELS, ]), "user-instructions": Schema.Literals(["keep", "drop"]), "dry-run": Schema.Boolean, @@ -2739,9 +2761,15 @@ const main = Effect.gen(function* () { } return; } - const apiKey = yield* Config.String("ANTHROPIC_API_KEY").pipe(Config.withDefault("")); + const morph = isMorph(flags.model); + if (morph !== isMorph(flags["shell-model"])) { + return yield* Effect.die(new Error("A Morph agent needs a Morph shell model, and only then.")); + } + const apiKey = morph + ? "" + : yield* Config.String("ANTHROPIC_API_KEY").pipe(Config.withDefault("")); const out = flags.out; - if ((!apiKey && !codex) || out === undefined) { + if ((!apiKey && !codex && !morph) || out === undefined) { const message = "Set ANTHROPIC_API_KEY and pass --out . ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL are never used."; return yield* Effect.die(new Error(message)); @@ -2749,7 +2777,11 @@ const main = Effect.gen(function* () { const config: Config = { apiKey, model: flags.model, - ...(codex || !isPricedModel(flags["shell-model"]) ? { proxy: proxyConfig() } : {}), + ...(morph + ? { proxy: morphConfig() } + : codex || !isPricedModel(flags["shell-model"]) + ? { proxy: proxyConfig() } + : {}), effort, maxSteps: flags["max-steps"] ?? (codex ? 10 : 6), shellModel: flags["shell-model"], diff --git a/evals/shared/proxy.ts b/evals/shared/proxy.ts index ede72be8fdab2..fb4f123a2ad4e 100644 --- a/evals/shared/proxy.ts +++ b/evals/shared/proxy.ts @@ -31,3 +31,33 @@ print(json.dumps({'url': p['base_url'].rstrip('/'), 'headers': h})) ), ), ); + +/** + * Morph's free OpenAI-compatible API, for evals that should not spend on paid models. The key is + * `MORPH_API_KEY`, else the `morph` provider in OpenCode's config (`$XDG_CONFIG_HOME` or `~/.config`). + */ +export const morphConfig = () => + decodeProxyConfig( + JSON.parse( + NodeChildProcess.execFileSync( + "python3", + [ + "-c", + ` +import json, os, pathlib +key = os.environ.get('MORPH_API_KEY') +url = os.environ.get('MORPH_BASE_URL', 'https://api.morphllm.com/v1') +if not key: + home = pathlib.Path(os.environ.get('XDG_CONFIG_HOME') or pathlib.Path.home() / '.config') + # OpenCode writes literal control characters inside strings, which strict parsing rejects. + settings = json.loads((home / 'opencode' / 'opencode.json').read_text(), strict=False)['providers']['morph']['settings'] + key, url = settings.get('apiKey'), settings.get('baseURL', url) +if not key: + raise SystemExit('no morph key') +print(json.dumps({'url': url.rstrip('/'), 'headers': {'Authorization': 'Bearer ' + key}})) +`, + ], + { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }, + ), + ), + ); diff --git a/packages/provider-core/src/server/conversationEvidence.ts b/packages/provider-core/src/server/conversationEvidence.ts index 0100978865ad1..c9c7ad9c46209 100644 --- a/packages/provider-core/src/server/conversationEvidence.ts +++ b/packages/provider-core/src/server/conversationEvidence.ts @@ -12,6 +12,13 @@ export const summaryToolTypes = [ "error", ] as const; +export const turnStartHistoryTypes = [ + "user_message", + "assistant_message", + "run_interrupt_result", + ...summaryToolTypes, +] as const; + /** Only user-visible evidence; reasoning, credentials and approval payloads are not sources. */ export function summaryToolText(item: OrchestrationV2TurnItem): string | null { if (!finalizedToolStatuses.some((status) => status === item.status)) return null;