Skip to content
38 changes: 38 additions & 0 deletions apps/server/src/provider/Layers/CodexAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,44 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
}),
);

it.effect("preserves parent linkage on terminal child metadata patches", () =>
Effect.gen(function* () {
const { adapter, runtime } = yield* startLifecycleRuntime();
const eventFiber = yield* Stream.runHead(adapter.streamEvents).pipe(Effect.forkChild);

yield* runtime.emit({
id: asEventId("evt-child-failed-metadata"),
kind: "notification",
provider: ProviderDriverKind.make("codex"),
createdAt: "2026-01-01T00:00:00.000Z",
method: "collabAgent/statusChanged",
threadId: asThreadId("thread-1"),
turnId: asTurnId("turn-1"),
payload: {
agentThreadId: "child-1",
agentPath: "/root/audit",
parentThreadId: "workflow-1",
status: { type: "systemError" },
},
});

const event = yield* Fiber.join(eventFiber);
NodeAssert.equal(event._tag, "Some");
if (event._tag === "Some") {
NodeAssert.equal(event.value.type, "task.updated");
NodeAssert.deepStrictEqual(event.value.payload, {
taskId: "child-1",
status: "failed",
role: "audit",
title: "audit",
agentPath: "/root/audit",
parentAgentId: "workflow-1",
timelineBypass: true,
});
}
}),
);

it.effect("maps completed agent message items to canonical item.completed events", () =>
Effect.gen(function* () {
const { adapter, runtime } = yield* startLifecycleRuntime();
Expand Down
3 changes: 3 additions & 0 deletions apps/server/src/provider/Layers/CodexAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,9 @@ function mapCollabAgentEvent(
role,
...(knownName ? { title: knownName } : {}),
...(agentPath ? { agentPath } : {}),
...(typeof payload.parentThreadId === "string"
? { parentAgentId: payload.parentThreadId }
: {}),
timelineBypass: true,
} as const;

Expand Down
Loading
Loading