fix: replies fail after transcript projection repair (#121025)

* fix(reply): rebind prepared session ownership

* test(mcp): correlate queued wait events

* fix(sessions): await transcript admission projection

* fix(recovery): distinguish admission failure stages

* refactor(sessions): split runtime transcript projection

* fix(ci): preserve transcript API baseline

* fix(sessions): await target projection only
This commit is contained in:
Peter Steinberger
2026-08-09 05:54:39 -07:00
committed by GitHub
parent 6794fc0fc8
commit dfbc95e4ea
8 changed files with 214 additions and 40 deletions
@@ -234,17 +234,38 @@ async function main() {
"expected one seeded attachment",
);
let waitCursor = 0;
let lastWaitEvent: Record<string, unknown> | undefined;
const waitMessage = `wait event ${randomUUID()}`;
const [waited, waitRun] = await Promise.all([
callTool<{
structuredContent?: { event?: Record<string, unknown> };
}>({
name: "events_wait",
arguments: {
session_key: "agent:main:main",
after_cursor: 0,
timeout_ms: 120_000,
const [waitEvent, waitRun] = await Promise.all([
waitFor(
"correlated events_wait user event",
async () => {
const waited = await callTool<{
structuredContent?: { event?: Record<string, unknown> };
}>({
name: "events_wait",
arguments: {
session_key: "agent:main:main",
after_cursor: waitCursor,
timeout_ms: 15_000,
},
});
const event = waited.structuredContent?.event;
if (!event) {
return undefined;
}
assert(typeof event.cursor === "number", "expected events_wait cursor");
waitCursor = event.cursor;
lastWaitEvent = event;
return event.text === waitMessage ? event : undefined;
},
120_000,
).catch((error: unknown) => {
throw new Error(
`events_wait did not return the expected user event: ${JSON.stringify(lastWaitEvent)}`,
{ cause: error },
);
}),
gateway.request<{ runId?: string; status?: string }>("chat.send", {
sessionKey: "agent:main:main",
@@ -252,12 +273,9 @@ async function main() {
idempotencyKey: randomUUID(),
}),
]);
const waitEvent = waited.structuredContent?.event;
assert(waitEvent, "expected events_wait result");
assert(waitEvent.type === "message", "expected message event");
assert(waitEvent.role === "user", "expected user event role");
assert(waitEvent.text === waitMessage, "expected wait event text");
const waitCursor = typeof waitEvent.cursor === "number" ? waitEvent.cursor : 0;
assert(
waitRun.status === "started" && typeof waitRun.runId === "string",
`chat.send did not start: ${JSON.stringify(waitRun)}`,