Share Codex sessions across orchestration threads

- Track explicit thread-to-session bindings and detach without stopping siblings
- Apply runtime settings per Codex thread and filter multiplexed events by turn
- Add migration, projection, lifecycle, and concurrency coverage
This commit is contained in:
Julius Marminge authored and Julius Marminge committed 2026-08-14 11:22:52 +02:00
1 parent 12173fe8e9
commit 27da49519f
30 files changed
+1798 -358

No files matched your search

@@ -23,7 +23,7 @@ import type { EventNdjsonLogger } from "../../provider/Layers/EventNdjsonLogger.
import {
buildCodexTurnStartParams,
CODEX_DRIVER_KIND,
codexAppServerMcpLaunchConfig,
codexThreadRuntimeParams,
makeCodexAppServerProtocolLogger,
makeCodexAppServerSpawnCommand,
projectCodexDynamicToolItem,
@@ -82,7 +82,7 @@ describe("CodexAdapterV2 runtime policy", () => {
});
describe("CodexAdapterV2 process spawning", () => {
it("injects the thread-scoped MCP endpoint and bearer token", () => {
it("injects cwd, model, and MCP authorization into thread-scoped params", () => {
const threadId = ThreadId.make("thread-codex-mcp");
McpProviderSession.setMcpProviderSession({
environmentId: EnvironmentId.make("environment-codex-mcp"),
@@ -94,17 +94,31 @@ describe("CodexAdapterV2 process spawning", () => {
});
try {
assert.deepEqual(codexAppServerMcpLaunchConfig(threadId), {
args: [
"-c",
"mcp_servers.t3-code.url=http://127.0.0.1:43123/mcp",
"-c",
'mcp_servers.t3-code.bearer_token_env_var="T3_MCP_BEARER_TOKEN"',
],
environment: {
T3_MCP_BEARER_TOKEN: "secret-codex-token",
assert.deepEqual(
codexThreadRuntimeParams({
threadId,
modelSelection: { model: "gpt-5.4" },
runtimePolicy: {
runtimeMode: "full-access",
interactionMode: "default",
cwd: "/workspace/thread-codex-mcp",
},
}),
{
cwd: "/workspace/thread-codex-mcp",
model: "gpt-5.4",
config: {
mcp_servers: {
"t3-code": {
url: "http://127.0.0.1:43123/mcp",
http_headers: {
Authorization: "Bearer secret-codex-token",
},
},
},
},
},
});
);
} finally {
McpProviderSession.clearMcpProviderSession(threadId);
}
@@ -248,7 +262,14 @@ describe("CodexAdapterV2 native protocol logging", () => {
yield* protocolLogger({
direction: "incoming",
stage: "decoded",
payload: { method: "thread/event", params: { id: "evt-1" } },
payload: {
method: "thread/event",
params: {
id: "evt-1",
http_headers: { Authorization: "Bearer secret-codex-token" },
usage: { inputTokens: 12, outputTokens: 8, totalTokens: 20 },
},
},
});
assert.equal(writes.length, 1);
@@ -261,7 +282,14 @@ describe("CodexAdapterV2 native protocol logging", () => {
event: {
direction: "incoming",
stage: "decoded",
payload: { method: "thread/event", params: { id: "evt-1" } },
payload: {
method: "thread/event",
params: {
id: "evt-1",
http_headers: { Authorization: "[REDACTED]" },
usage: { inputTokens: 12, outputTokens: 8, totalTokens: 20 },
},
},
},
});
}),
@@ -769,24 +769,35 @@ export class CodexAppServerClientFactory extends Context.Service<
CodexAppServerClientFactoryShape
>()("t3/orchestration-v2/Adapters/CodexAdapterV2/CodexAppServerClientFactory") {}
export function codexAppServerMcpLaunchConfig(threadId: ThreadId): {
readonly args: ReadonlyArray<string>;
readonly environment: NodeJS.ProcessEnv;
} | null {
const session = McpProviderSession.readMcpProviderSession(threadId);
return session === undefined
? null
: {
args: [
"-c",
`mcp_servers.t3-code.url=${session.endpoint}`,
"-c",
'mcp_servers.t3-code.bearer_token_env_var="T3_MCP_BEARER_TOKEN"',
],
environment: {
T3_MCP_BEARER_TOKEN: session.authorizationHeader.replace(/^Bearer\s+/, ""),
},
};
export function codexThreadRuntimeParams(input: {
readonly threadId: ThreadId | null;
readonly modelSelection?: { readonly model: string };
readonly runtimePolicy?: ProviderAdapterV2RuntimePolicy;
}): {
readonly cwd?: string;
readonly model?: string;
readonly config?: Readonly<Record<string, unknown>>;
} {
const mcpSession =
input.threadId === null ? undefined : McpProviderSession.readMcpProviderSession(input.threadId);
return {
...(input.runtimePolicy?.cwd == null ? {} : { cwd: input.runtimePolicy.cwd }),
...(input.modelSelection === undefined ? {} : { model: input.modelSelection.model }),
...(mcpSession === undefined
? {}
: {
config: {
mcp_servers: {
"t3-code": {
url: mcpSession.endpoint,
http_headers: {
Authorization: mcpSession.authorizationHeader,
},
},
},
},
}),
};
}
export const makeCodexAppServerSpawnCommand = Effect.fn(
@@ -826,22 +837,11 @@ export const makeCodexAppServerClientFactoryCommandLayer = (
open: (input) =>
Effect.gen(function* () {
const scope = yield* Scope.Scope;
const mcp = codexAppServerMcpLaunchConfig(input.threadId);
const command = yield* makeCodexAppServerSpawnCommand({
command: options.command,
args: [...(options.args ?? []), ...(mcp?.args ?? [])],
...((input.runtimePolicy.cwd ?? options.cwd) === undefined
? {}
: { cwd: input.runtimePolicy.cwd ?? options.cwd }),
...(options.env === undefined && mcp === null
? {}
: {
env: {
...options.env,
...mcp?.environment,
},
extendEnv: true,
}),
args: [...(options.args ?? [])],
...(options.cwd === undefined ? {} : { cwd: options.cwd }),
...(options.env === undefined ? {} : { env: options.env, extendEnv: true }),
});
const handle = yield* spawner.spawn(command).pipe(
Effect.provideService(Scope.Scope, scope),
@@ -881,13 +881,39 @@ export function makeCodexAppServerProtocolLogger(input: {
protocol: "codex.app-server",
kind: "protocol",
providerSessionId: input.providerSessionId,
event,
event: redactCodexProtocolValue(event),
},
input.threadId,
)
.pipe(Effect.ignore);
}
export function redactCodexProtocolValue(value: unknown): unknown {
if (Array.isArray(value)) {
return value.map(redactCodexProtocolValue);
}
if (value === null || typeof value !== "object") {
return typeof value === "string" && /^Bearer\s+/i.test(value) ? "[REDACTED]" : value;
}
return Object.fromEntries(
Object.entries(value).map(([key, nested]) => [
key,
isSensitiveCodexProtocolKey(key) ? "[REDACTED]" : redactCodexProtocolValue(nested),
]),
);
}
function isSensitiveCodexProtocolKey(key: string): boolean {
const normalized = key.replace(/[^a-z0-9]/gi, "").toLowerCase();
return (
normalized.endsWith("authorization") ||
normalized.endsWith("apikey") ||
normalized.endsWith("token") ||
normalized.endsWith("password") ||
normalized.endsWith("secret")
);
}
export const codexAppServerClientFactoryFromSettingsLayer: Layer.Layer<
CodexAppServerClientFactory,
never,
@@ -906,16 +932,13 @@ export const codexAppServerClientFactoryFromSettingsLayer: Layer.Layer<
open: (input) =>
Effect.gen(function* () {
const scope = yield* Scope.Scope;
const mcp = codexAppServerMcpLaunchConfig(input.threadId);
const environment = {
...input.environment,
...(input.settings.homePath ? { CODEX_HOME: input.settings.homePath } : {}),
...mcp?.environment,
};
const command = yield* makeCodexAppServerSpawnCommand({
command: input.settings.binaryPath || "codex",
args: ["app-server", ...(mcp?.args ?? [])],
...(input.runtimePolicy.cwd === null ? {} : { cwd: input.runtimePolicy.cwd }),
args: ["app-server"],
env: environment,
});
const handle = yield* spawner.spawn(command).pipe(
@@ -3876,7 +3899,16 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
events: Stream.fromEffectRepeat(Queue.take(events)),
ensureThread: (threadInput) =>
ensureInitialized.pipe(
Effect.andThen(client.request("thread/start", {})),
Effect.andThen(
client.request(
"thread/start",
codexThreadRuntimeParams({
threadId: threadInput.threadId,
modelSelection: threadInput.modelSelection,
runtimePolicy: threadInput.runtimePolicy,
}),
),
),
Effect.map(
(response): OrchestrationV2ProviderThread =>
providerThreadFromCodexThread({
@@ -3905,7 +3937,20 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
}
const response = yield* ensureInitialized.pipe(
Effect.andThen(client.request("thread/resume", { threadId: nativeThreadId })),
Effect.andThen(
client.request("thread/resume", {
threadId: nativeThreadId,
...codexThreadRuntimeParams({
threadId: threadInput.threadId ?? threadInput.providerThread.appThreadId,
...(threadInput.modelSelection === undefined
? {}
: { modelSelection: threadInput.modelSelection }),
...(threadInput.runtimePolicy === undefined
? {}
: { runtimePolicy: threadInput.runtimePolicy }),
}),
}),
),
);
return {
...threadInput.providerThread,
@@ -4335,7 +4380,20 @@ export function makeCodexAdapterV2(adapterOptions: CodexAdapterV2Options): Provi
Effect.gen(function* () {
const threadId = yield* getNativeThreadId(threadInput.sourceProviderThread);
const response = yield* ensureInitialized.pipe(
Effect.andThen(client.request("thread/fork", { threadId })),
Effect.andThen(
client.request("thread/fork", {
threadId,
...codexThreadRuntimeParams({
threadId: threadInput.targetThreadId,
...(threadInput.modelSelection === undefined
? {}
: { modelSelection: threadInput.modelSelection }),
...(threadInput.runtimePolicy === undefined
? {}
: { runtimePolicy: threadInput.runtimePolicy }),
}),
}),
),
Effect.mapError(
(cause) =>
new ProviderAdapterForkThreadError({
@@ -105,7 +105,9 @@ const DEFAULT_OPENCODE_SETTINGS = Schema.decodeSync(OpenCodeSettingsSchema)({});
*/
export const OpenCodeProviderCapabilitiesV2 = {
sessions: {
supportsMultipleProviderThreadsPerSession: true,
// The current adapter owns one directory-bound client/server per session.
// Keep it isolated until its runtime is made safe for cross-thread pooling.
supportsMultipleProviderThreadsPerSession: false,
supportsModelSwitchInSession: true,
supportsProviderSwitchingViaHandoff: true,
supportsRuntimeModeSwitchInSession: false,
@@ -24,14 +24,8 @@ import * as SqlClient from "effect/unstable/sql/SqlClient";
export const OrchestrationEffectRequestV2 = Schema.Union([
Schema.Struct({
type: Schema.Literal("provider-session.release"),
type: Schema.Literal("provider-session.detach"),
providerSessionId: ProviderSessionId,
reason: Schema.Literals([
"idle_timeout",
"runtime_error",
"manual_shutdown",
"server_shutdown",
]),
detail: Schema.optional(Schema.String),
}),
Schema.Struct({
@@ -56,11 +56,11 @@ export const executorLayer: Layer.Layer<
return OrchestrationEffectExecutorV2.of({
execute: (effect) => {
switch (effect.request.type) {
case "provider-session.release":
case "provider-session.detach":
return providerSessions
.release({
.detach({
providerSessionId: effect.request.providerSessionId,
reason: effect.request.reason,
threadId: effect.threadId,
...(effect.request.detail === undefined ? {} : { detail: effect.request.detail }),
})
.pipe(
+10 -2
View File
@@ -25,7 +25,10 @@ import {
layer as effectOutboxLayer,
} from "./EffectOutbox.ts";
import { EventStoreV2 } from "./EventStore.ts";
import { ProjectionStoreV2 } from "./ProjectionStore.ts";
import {
ORCHESTRATION_V2_PROJECTION_SCHEMA_VERSION,
ProjectionStoreV2,
} from "./ProjectionStore.ts";
import {
TurnItemPositionStoreV2,
layer as turnItemPositionStoreLayer,
@@ -177,7 +180,12 @@ const baseLayer: Layer.Layer<
last_sequence,
updated_at
)
VALUES ('thread-projections', 1, ${sequence}, ${now})
VALUES (
'thread-projections',
${ORCHESTRATION_V2_PROJECTION_SCHEMA_VERSION},
${sequence},
${now}
)
ON CONFLICT(projection_name)
DO UPDATE SET
schema_version = excluded.schema_version,
@@ -127,6 +127,9 @@ export interface IdAllocatorV2AllocateShape {
}
export interface IdAllocatorV2DeriveShape {
readonly providerSession: (input: {
readonly providerInstanceId: ProviderInstanceId;
}) => ProviderSessionId;
readonly delegatedTaskNode: (input: { readonly commandId: CommandId }) => NodeId;
readonly delegatedTaskThread: (input: { readonly commandId: CommandId }) => ThreadId;
readonly delegatedTaskMessage: (input: { readonly commandId: CommandId }) => MessageId;
@@ -343,6 +346,10 @@ export const layer: Layer.Layer<IdAllocatorV2> = Layer.succeed(
})(input),
},
derive: {
providerSession: (input) =>
ProviderSessionId.make(
joinId("provider-session", "provider-instance", input.providerInstanceId, "shared"),
),
delegatedTaskNode: (input) => NodeId.make(joinId("node", "delegated-task", input.commandId)),
delegatedTaskThread: (input) =>
ThreadId.make(joinId("thread", "delegated-task", input.commandId)),
+124 -76
View File
@@ -42,6 +42,7 @@ import type { PendingOrchestrationEffectV2 } from "./EffectOutbox.ts";
import { OrchestrationEffectWorkerV2 } from "./EffectWorker.ts";
import { IdAllocatorV2 } from "./IdAllocator.ts";
import { applyToProjection, emptyProjection, ProjectionStoreV2 } from "./ProjectionStore.ts";
import type { ProviderAdapterV2Shape } from "./ProviderAdapter.ts";
import { ProviderAdapterRegistryV2 } from "./ProviderAdapterRegistry.ts";
import { ProviderSessionManagerV2 } from "./ProviderSessionManager.ts";
import { ProviderSwitchServiceV2 } from "./ProviderSwitchService.ts";
@@ -174,7 +175,7 @@ function commandThreadId(command: OrchestrationV2Command): ThreadId {
case "thread.runtime-mode.set":
case "thread.interaction-mode.set":
case "thread.model-selection.set":
case "provider-session.release":
case "provider-session.detach":
case "message.dispatch":
case "run.interrupt":
case "queued-message.promote-to-steer":
@@ -409,6 +410,26 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
),
);
const providerSessionIdFor = (input: {
readonly adapter: ProviderAdapterV2Shape;
readonly providerInstanceId: ProviderInstanceId;
readonly threadId: ThreadId;
}) =>
input.adapter.getCapabilities().pipe(
Effect.flatMap((capabilities) =>
capabilities.sessions.supportsMultipleProviderThreadsPerSession
? Effect.succeed(
idAllocator.derive.providerSession({
providerInstanceId: input.providerInstanceId,
}),
)
: idAllocator.allocate.providerSession({
providerInstanceId: input.providerInstanceId,
threadId: input.threadId,
}),
),
);
const enforceCommandPolicy =
(command: OrchestrationV2Command) =>
<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, OrchestratorDispatchError, R> =>
@@ -547,12 +568,26 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
});
}
const commandId = CommandId.make(`command:system:start-queued:${queuedRun.id}`);
const providerSessionId =
queuedProviderThread.providerSessionId ??
(yield* idAllocator.allocate.providerSession({
providerInstanceId: queuedRun.providerInstanceId,
threadId,
}));
(yield* providerAdapters.get(queuedRun.providerInstanceId).pipe(
Effect.flatMap((adapter) =>
providerSessionIdFor({
adapter,
providerInstanceId: queuedRun.providerInstanceId,
threadId,
}),
),
Effect.mapError(
(cause) =>
new OrchestratorDispatchError({
commandId,
commandType: "message.dispatch",
cause,
}),
),
));
const now = yield* DateTime.now;
const providerThread: OrchestrationV2ProviderThread = {
...queuedProviderThread,
@@ -568,8 +603,6 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
queuePosition: null,
startedAt: null,
};
const commandId = CommandId.make(`command:system:start-queued:${queuedRun.id}`);
yield* writeSystemEvents(
[
{
@@ -782,7 +815,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
payload: updatedThread,
});
const releaseSessionIds = new Set(
const detachSessionIds = new Set(
command.type === "thread.archive" || command.type === "thread.delete"
? projection.providerSessions.map((session) => session.id)
: command.type === "thread.runtime-mode.set"
@@ -793,10 +826,10 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
.map((session) => session.id)
: (providerSwitchPlan?.releaseProviderSessionIds ?? []),
);
if (releaseSessionIds.size > 0) {
if (detachSessionIds.size > 0) {
const liveSessions = projection.providerSessions.filter(
(session) =>
releaseSessionIds.has(session.id) &&
detachSessionIds.has(session.id) &&
session.status !== "stopped" &&
session.status !== "error",
);
@@ -808,21 +841,31 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
events,
command,
)({
type: "provider-session.updated",
type: "provider-session.detached",
threadId: command.threadId,
driver: session.driver,
providerInstanceId: session.providerInstanceId,
occurredAt: now,
payload: { ...session, status: "stopped", updatedAt: now },
payload: {
providerSessionId: session.id,
detachedAt: now,
reason:
command.type === "thread.archive"
? "Thread archived."
: command.type === "thread.delete"
? "Thread deleted."
: command.type === "thread.runtime-mode.set"
? "Runtime mode changed."
: "Provider or model selection changed.",
},
});
const pendingEffect = {
id: `effect:${command.commandId}:provider-session.release:${session.id}`,
id: `effect:${command.commandId}:provider-session.detach:${session.id}`,
commandId: command.commandId,
threadId: command.threadId,
request: {
type: "provider-session.release",
type: "provider-session.detach",
providerSessionId: session.id,
reason: "manual_shutdown",
detail:
command.type === "thread.archive"
? "Thread archived."
@@ -840,55 +883,58 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
}
});
const dispatchProviderSessionRelease = Effect.fn(
"orchestrationV2.dispatch.providerSessionRelease",
)(function* (
command: Extract<OrchestrationV2Command, { readonly type: "provider-session.release" }>,
events: Ref.Ref<Array<OrchestrationV2DomainEvent>>,
effects: Ref.Ref<Array<PendingOrchestrationEffectV2>>,
) {
const projection = yield* projectionStore
.getThreadProjection(command.threadId)
.pipe(
Effect.mapError(
(cause) => new OrchestratorProjectionError({ threadId: command.threadId, cause }),
),
const dispatchProviderSessionDetach = Effect.fn("orchestrationV2.dispatch.providerSessionDetach")(
function* (
command: Extract<OrchestrationV2Command, { readonly type: "provider-session.detach" }>,
events: Ref.Ref<Array<OrchestrationV2DomainEvent>>,
effects: Ref.Ref<Array<PendingOrchestrationEffectV2>>,
) {
const projection = yield* projectionStore
.getThreadProjection(command.threadId)
.pipe(
Effect.mapError(
(cause) => new OrchestratorProjectionError({ threadId: command.threadId, cause }),
),
);
const session = projection.providerSessions.find(
(candidate) => candidate.id === command.providerSessionId,
);
const session = projection.providerSessions.find(
(candidate) => candidate.id === command.providerSessionId,
);
if (session === undefined) {
return yield* new OrchestratorDispatchError({
commandId: command.commandId,
commandType: command.type,
cause: `Provider session ${command.providerSessionId} does not belong to thread ${command.threadId}.`,
if (session === undefined) {
return yield* new OrchestratorDispatchError({
commandId: command.commandId,
commandType: command.type,
cause: `Provider session ${command.providerSessionId} does not belong to thread ${command.threadId}.`,
});
}
const now = yield* DateTime.now;
yield* emit(
events,
command,
)({
type: "provider-session.detached",
threadId: command.threadId,
driver: session.driver,
providerInstanceId: session.providerInstanceId,
occurredAt: now,
payload: {
providerSessionId: session.id,
detachedAt: now,
...(command.reason === undefined ? {} : { reason: command.reason }),
},
});
}
const now = yield* DateTime.now;
yield* emit(
events,
command,
)({
type: "provider-session.updated",
threadId: command.threadId,
driver: session.driver,
providerInstanceId: session.providerInstanceId,
occurredAt: now,
payload: { ...session, status: "stopped", updatedAt: now },
});
const pendingEffect = {
id: `effect:${command.commandId}:provider-session.release:${command.providerSessionId}`,
commandId: command.commandId,
threadId: command.threadId,
request: {
type: "provider-session.release",
providerSessionId: command.providerSessionId,
reason: "manual_shutdown",
...(command.reason === undefined ? {} : { detail: command.reason }),
},
} satisfies PendingOrchestrationEffectV2;
yield* Ref.update(effects, (existing) => [...existing, pendingEffect]);
});
const pendingEffect = {
id: `effect:${command.commandId}:provider-session.detach:${command.providerSessionId}`,
commandId: command.commandId,
threadId: command.threadId,
request: {
type: "provider-session.detach",
providerSessionId: command.providerSessionId,
...(command.reason === undefined ? {} : { detail: command.reason }),
},
} satisfies PendingOrchestrationEffectV2;
yield* Ref.update(effects, (existing) => [...existing, pendingEffect]);
},
);
const dispatchThreadFork = Effect.fn("orchestrationV2.dispatch.threadFork")(function* (
command: Extract<OrchestrationV2Command, { readonly type: "thread.fork" }>,
@@ -1799,7 +1845,8 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
const providerSessionId =
activeProviderThread?.providerSessionId ??
(yield* mapDispatchError(command)(
idAllocator.allocate.providerSession({
providerSessionIdFor({
adapter,
providerInstanceId: modelSelection.instanceId,
threadId: command.threadId,
}),
@@ -2059,13 +2106,24 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
}
}
const adapter = yield* providerAdapters.get(modelSelection.instanceId).pipe(
Effect.mapError(
(cause) =>
new OrchestratorProviderAdapterError({
commandId: command.commandId,
providerInstanceId: modelSelection.instanceId,
cause,
}),
),
);
const targetProviderThread = isProviderSwitch
? rootProviderThreadsForProvider(projection, modelSelection.instanceId)[0]
: activeProviderThread;
const providerSessionId =
targetProviderThread?.providerSessionId ??
(yield* mapDispatchError(command)(
idAllocator.allocate.providerSession({
providerSessionIdFor({
adapter,
providerInstanceId: modelSelection.instanceId,
threadId: command.threadId,
}),
@@ -2086,16 +2144,6 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
),
);
const adapter = yield* providerAdapters.get(modelSelection.instanceId).pipe(
Effect.mapError(
(cause) =>
new OrchestratorProviderAdapterError({
commandId: command.commandId,
providerInstanceId: modelSelection.instanceId,
cause,
}),
),
);
const capabilities = yield* adapter.getCapabilities().pipe(
Effect.mapError(
(cause) =>
@@ -3945,8 +3993,8 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
case "provider.switch":
yield* dispatchThreadMutation(command, events, effects);
break;
case "provider-session.release":
yield* dispatchProviderSessionRelease(command, events, effects);
case "provider-session.detach":
yield* dispatchProviderSessionDetach(command, events, effects);
break;
case "message.dispatch":
yield* dispatchMessage(command, events, effects);
@@ -204,6 +204,7 @@ export const layer: Layer.Layer<
yield* sql`DELETE FROM orchestration_v2_projection_runtime_requests`;
yield* sql`DELETE FROM orchestration_v2_projection_provider_turns`;
yield* sql`DELETE FROM orchestration_v2_projection_provider_threads`;
yield* sql`DELETE FROM orchestration_v2_projection_provider_session_bindings`;
yield* sql`DELETE FROM orchestration_v2_projection_provider_sessions`;
yield* sql`DELETE FROM orchestration_v2_projection_subagents`;
yield* sql`DELETE FROM orchestration_v2_projection_nodes`;
@@ -7,6 +7,7 @@ import {
ProjectId,
ProviderDriverKind,
ProviderInstanceId,
ProviderSessionId,
ProviderThreadId,
ProviderTurnId,
RunAttemptId,
@@ -21,6 +22,7 @@ import * as Schema from "effect/Schema";
import * as SqlClient from "effect/unstable/sql/SqlClient";
import { SqlitePersistenceMemory } from "../persistence/Layers/Sqlite.ts";
import { CodexProviderCapabilitiesV2 } from "./Adapters/CodexAdapterV2.ts";
import { ProjectionStoreV2, layer as projectionStoreLayer } from "./ProjectionStore.ts";
const TestLayer = Layer.mergeAll(
@@ -36,6 +38,116 @@ const providerInstanceId = modelSelection.instanceId;
const encodeUnknownJsonString = Schema.encodeSync(Schema.fromJsonString(Schema.Unknown));
it.layer(TestLayer)("ProjectionStoreV2", (it) => {
it.effect("projects one shared provider session into multiple thread bindings", () =>
Effect.gen(function* () {
const projectionStore = yield* ProjectionStoreV2;
const now = yield* DateTime.now;
const projectId = ProjectId.make("project:projection-shared-provider-session");
const firstThreadId = ThreadId.make("thread:projection-shared-provider-session:first");
const secondThreadId = ThreadId.make("thread:projection-shared-provider-session:second");
const providerSessionId = ProviderSessionId.make(
"provider-session:projection-shared-provider-session",
);
const makeThread = (threadId: ThreadId) => ({
createdBy: "user" as const,
creationSource: "web" as const,
id: threadId,
projectId,
title: "Shared provider session",
providerInstanceId,
modelSelection,
runtimeMode: "full-access" as const,
interactionMode: "default" as const,
branch: null,
worktreePath: null,
activeProviderThreadId: null,
lineage: {
parentThreadId: null,
relationshipToParent: null,
rootThreadId: threadId,
},
forkedFrom: null,
createdAt: now,
updatedAt: now,
archivedAt: null,
deletedAt: null,
});
const session = {
id: providerSessionId,
driver,
providerInstanceId,
status: "ready" as const,
cwd: "/workspace",
model: modelSelection.model,
capabilities: CodexProviderCapabilitiesV2,
createdAt: now,
updatedAt: now,
lastError: null,
};
yield* projectionStore.apply({
id: EventId.make("event:projection-shared-provider-session:first-thread"),
type: "thread.created",
threadId: firstThreadId,
occurredAt: now,
payload: makeThread(firstThreadId),
});
yield* projectionStore.apply({
id: EventId.make("event:projection-shared-provider-session:second-thread"),
type: "thread.created",
threadId: secondThreadId,
occurredAt: now,
payload: makeThread(secondThreadId),
});
for (const [threadId, suffix] of [
[firstThreadId, "first"],
[secondThreadId, "second"],
] as const) {
yield* projectionStore.apply({
id: EventId.make(`event:projection-shared-provider-session:${suffix}-binding`),
type: "provider-session.attached",
threadId,
driver,
providerInstanceId,
occurredAt: now,
payload: session,
});
}
assert.deepEqual(
(yield* projectionStore.getThreadProjection(firstThreadId)).providerSessions.map(
(value) => value.id,
),
[providerSessionId],
);
assert.deepEqual(
(yield* projectionStore.getThreadProjection(secondThreadId)).providerSessions.map(
(value) => value.id,
),
[providerSessionId],
);
yield* projectionStore.apply({
id: EventId.make("event:projection-shared-provider-session:first-detached"),
type: "provider-session.detached",
threadId: firstThreadId,
driver,
providerInstanceId,
occurredAt: now,
payload: { providerSessionId, detachedAt: now },
});
assert.lengthOf(
(yield* projectionStore.getThreadProjection(firstThreadId)).providerSessions,
0,
);
assert.lengthOf(
(yield* projectionStore.getThreadProjection(secondThreadId)).providerSessions,
1,
);
}),
);
it.effect("builds shell snapshots without decoding full turn item payloads", () =>
Effect.gen(function* () {
const projectionStore = yield* ProjectionStoreV2;
@@ -130,12 +242,14 @@ it.layer(TestLayer)("ProjectionStoreV2", (it) => {
const fullProjectionExit = yield* Effect.exit(projectionStore.getThreadProjection(threadId));
assert.deepEqual(
shell.threads.map((thread) => ({
id: thread.id,
itemCount: thread.itemCount,
visibleItemCount: thread.visibleItemCount,
status: thread.status,
})),
shell.threads
.filter((thread) => thread.id === threadId)
.map((thread) => ({
id: thread.id,
itemCount: thread.itemCount,
visibleItemCount: thread.visibleItemCount,
status: thread.status,
})),
[
{
id: threadId,
@@ -120,7 +120,7 @@ export class ProjectionStoreV2 extends Context.Service<ProjectionStoreV2, Projec
"t3/orchestration-v2/ProjectionStore/ProjectionStoreV2",
) {}
export const ORCHESTRATION_V2_PROJECTION_SCHEMA_VERSION = 1;
export const ORCHESTRATION_V2_PROJECTION_SCHEMA_VERSION = 2;
function upsertById<T extends { readonly id: string }>(items: ReadonlyArray<T>, next: T): Array<T> {
const index = items.findIndex((item) => item.id === next.id);
@@ -207,11 +207,19 @@ export function applyToProjection(
...base,
subagents: upsertById(base.subagents, event.payload),
};
case "provider-session.attached":
case "provider-session.updated":
return {
...base,
providerSessions: upsertById(base.providerSessions, event.payload),
};
case "provider-session.detached":
return {
...base,
providerSessions: base.providerSessions.filter(
(session) => session.id !== event.payload.providerSessionId,
),
};
case "provider-thread.updated":
return {
...base,
@@ -1086,6 +1094,7 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
`;
break;
}
case "provider-session.attached":
case "provider-session.updated": {
const payloadJson = yield* encodeProviderSessionPayload(event.payload);
const payload = parseEncodedPayload(payloadJson);
@@ -1123,6 +1132,23 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
updated_at = excluded.updated_at,
payload_json = excluded.payload_json
`;
if (event.type === "provider-session.attached") {
yield* sql`
INSERT OR IGNORE INTO orchestration_v2_projection_provider_session_bindings (
provider_session_id,
thread_id
)
VALUES (${event.payload.id}, ${event.threadId})
`;
}
break;
}
case "provider-session.detached": {
yield* sql`
DELETE FROM orchestration_v2_projection_provider_session_bindings
WHERE provider_session_id = ${event.payload.providerSessionId}
AND thread_id = ${event.threadId}
`;
break;
}
case "provider-thread.updated": {
@@ -1676,10 +1702,12 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
ORDER BY COALESCE(started_at, ''), subagent_id ASC
`,
sql<PayloadRow>`
SELECT payload_json
FROM orchestration_v2_projection_provider_sessions
WHERE thread_id = ${threadId}
ORDER BY updated_at ASC, provider_session_id ASC
SELECT sessions.payload_json
FROM orchestration_v2_projection_provider_sessions AS sessions
INNER JOIN orchestration_v2_projection_provider_session_bindings AS bindings
ON bindings.provider_session_id = sessions.provider_session_id
WHERE bindings.thread_id = ${threadId}
ORDER BY sessions.updated_at ASC, sessions.provider_session_id ASC
`,
sql<PayloadRow>`
SELECT payload_json
@@ -432,6 +432,13 @@ export interface ProviderAdapterV2ForkThreadInput {
readonly providerTurnId?: ProviderTurnId;
readonly targetThreadId: ThreadId;
readonly ownerNodeId?: NodeId;
readonly modelSelection?: ModelSelection;
readonly runtimePolicy?: ProviderAdapterV2RuntimePolicy;
}
export interface ProviderAdapterV2EventSubscription {
readonly events: Stream.Stream<ProviderAdapterV2Event, ProviderAdapterV2Error>;
readonly close: Effect.Effect<void>;
}
export interface ProviderAdapterV2SessionRuntime {
@@ -441,11 +448,20 @@ export interface ProviderAdapterV2SessionRuntime {
readonly providerSession: OrchestrationV2ProviderSession;
readonly rawEvents: Stream.Stream<OrchestrationV2RawProviderEvent, ProviderAdapterV2Error>;
readonly events: Stream.Stream<ProviderAdapterV2Event, ProviderAdapterV2Error>;
/**
* Manager-owned runtimes expose a synchronous subscription so concurrent
* provider threads receive independent copies of the process event stream.
* Adapter runtimes may omit this and expose only their raw single-consumer stream.
*/
readonly subscribeEvents?: Effect.Effect<ProviderAdapterV2EventSubscription>;
readonly ensureThread: (
input: ProviderAdapterV2EnsureThreadInput,
) => Effect.Effect<OrchestrationV2ProviderThread, ProviderAdapterV2Error>;
readonly resumeThread: (input: {
readonly providerThread: OrchestrationV2ProviderThread;
readonly threadId?: ThreadId;
readonly modelSelection?: ModelSelection;
readonly runtimePolicy?: ProviderAdapterV2RuntimePolicy;
}) => Effect.Effect<OrchestrationV2ProviderThread, ProviderAdapterV2Error>;
readonly startTurn: (
input: ProviderAdapterV2TurnInput,
@@ -59,16 +59,27 @@ const TestEventSinkLayer = eventSinkLayer.pipe(
);
const CodexCapabilities: OrchestrationV2ProviderCapabilities = CodexProviderCapabilitiesV2;
const ExclusiveCapabilities: OrchestrationV2ProviderCapabilities = {
...CodexCapabilities,
sessions: {
...CodexCapabilities.sessions,
supportsMultipleProviderThreadsPerSession: false,
},
};
interface TestProviderRuntimeState {
readonly openCount: number;
readonly closeCount: number;
readonly interruptCount: number;
readonly resumeCount: number;
readonly eventQueues: ReadonlyMap<string, Queue.Queue<ProviderAdapterV2Event>>;
}
const emptyState: TestProviderRuntimeState = {
openCount: 0,
closeCount: 0,
interruptCount: 0,
resumeCount: 0,
eventQueues: new Map(),
};
@@ -87,6 +98,7 @@ const runtimePolicy = {
function makeProviderSession(input: {
readonly providerSessionId: ProviderSessionId;
readonly now: DateTime.Utc;
readonly capabilities?: OrchestrationV2ProviderCapabilities;
}): OrchestrationV2ProviderSession {
return {
id: input.providerSessionId,
@@ -95,7 +107,7 @@ function makeProviderSession(input: {
status: "ready",
cwd: process.cwd(),
model: "gpt-5.4",
capabilities: CodexCapabilities,
capabilities: input.capabilities ?? CodexCapabilities,
createdAt: input.now,
updatedAt: input.now,
lastError: null,
@@ -194,6 +206,7 @@ function makeProviderAdapter(
state: Ref.Ref<TestProviderRuntimeState>,
options: {
readonly failEventStream?: boolean;
readonly capabilities?: OrchestrationV2ProviderCapabilities;
readonly mcpConfigs?: Ref.Ref<
ReadonlyArray<McpProviderSession.McpProviderSessionConfig | undefined>
>;
@@ -202,7 +215,7 @@ function makeProviderAdapter(
return {
instanceId: ProviderInstanceId.make("codex"),
driver: CODEX_DRIVER,
getCapabilities: () => Effect.succeed(CodexCapabilities),
getCapabilities: () => Effect.succeed(options.capabilities ?? CodexCapabilities),
openSession: (input) =>
Effect.gen(function* () {
if (options.mcpConfigs !== undefined) {
@@ -216,6 +229,7 @@ function makeProviderAdapter(
const session = makeProviderSession({
providerSessionId: input.providerSessionId,
now,
...(options.capabilities === undefined ? {} : { capabilities: options.capabilities }),
});
yield* Ref.update(state, (current) => {
const eventQueues = new Map(current.eventQueues);
@@ -249,10 +263,18 @@ function makeProviderAdapter(
)
: Stream.fromQueue(events),
ensureThread: () => unimplemented("ensureThread unused in test"),
resumeThread: (threadInput) => Effect.succeed(threadInput.providerThread),
resumeThread: (threadInput) =>
Ref.update(state, (current) => ({
...current,
resumeCount: current.resumeCount + 1,
})).pipe(Effect.as(threadInput.providerThread)),
startTurn: () => Effect.void,
steerTurn: () => Effect.void,
interruptTurn: () => Effect.void,
interruptTurn: () =>
Ref.update(state, (current) => ({
...current,
interruptCount: current.interruptCount + 1,
})),
respondToRuntimeRequest: () => Effect.void,
readThreadSnapshot: () => unimplemented("readThreadSnapshot unused in test"),
rollbackThread: () => unimplemented("rollbackThread unused in test"),
@@ -266,6 +288,7 @@ function makeTestLayer(input: {
readonly state: Ref.Ref<TestProviderRuntimeState>;
readonly idleTimeoutMs: number;
readonly failEventStream?: boolean;
readonly capabilities?: OrchestrationV2ProviderCapabilities;
readonly mcpConfigs?: Ref.Ref<
ReadonlyArray<McpProviderSession.McpProviderSessionConfig | undefined>
>;
@@ -273,6 +296,7 @@ function makeTestLayer(input: {
const registryLayer = makeProviderAdapterRegistryLayer(
makeProviderAdapter(input.state, {
failEventStream: input.failEventStream ?? false,
...(input.capabilities === undefined ? {} : { capabilities: input.capabilities }),
...(input.mcpConfigs === undefined ? {} : { mcpConfigs: input.mcpConfigs }),
}),
);
@@ -964,6 +988,224 @@ it.effect(
}),
);
it.effect(
"ProviderSessionManagerV2 opens one shared runtime, broadcasts events, and detaches threads independently",
() =>
Effect.gen(function* () {
const state = yield* Ref.make(emptyState);
const effect = Effect.gen(function* () {
const eventSink = yield* EventSinkV2;
const idAllocator = yield* IdAllocatorV2;
const manager = yield* ProviderSessionManagerV2;
const now = yield* DateTime.now;
const projectId = yield* idAllocator.allocate.project({
fixtureName: "provider-session-manager-shared-runtime",
});
const firstThreadId = yield* idAllocator.allocate.thread({
fixtureName: "provider-session-manager-shared-runtime-a",
projectId,
});
const secondThreadId = yield* idAllocator.allocate.thread({
fixtureName: "provider-session-manager-shared-runtime-b",
projectId,
});
const providerSessionId = idAllocator.derive.providerSession({
providerInstanceId: modelSelection.instanceId,
});
yield* eventSink.write({
events: [
yield* makeThreadCreatedEvent({ idAllocator, threadId: firstThreadId, now }),
yield* makeThreadCreatedEvent({ idAllocator, threadId: secondThreadId, now }),
],
});
const firstProviderThread = makeProviderThread({
idAllocator,
threadId: firstThreadId,
providerSessionId,
now,
});
const secondProviderThread = makeProviderThread({
idAllocator,
threadId: secondThreadId,
providerSessionId,
now,
});
const firstRunId = idAllocator.derive.run({ threadId: firstThreadId, ordinal: 1 });
yield* eventSink.write({
events: [
{
id: yield* idAllocator.allocate.event({ threadId: firstThreadId }),
type: "provider-thread.updated",
threadId: firstThreadId,
driver: CODEX_DRIVER,
occurredAt: now,
payload: firstProviderThread,
},
{
id: yield* idAllocator.allocate.event({ threadId: firstThreadId }),
type: "provider-turn.updated",
threadId: firstThreadId,
runId: firstRunId,
driver: CODEX_DRIVER,
occurredAt: now,
payload: {
id: idAllocator.derive.providerTurn({
driver: CODEX_DRIVER,
nativeTurnId: "native-turn-shared-runtime-a",
}),
providerThreadId: firstProviderThread.id,
nodeId: idAllocator.derive.rootNode({ runId: firstRunId }),
runAttemptId: null,
nativeTurnRef: null,
ordinal: 1,
status: "running",
startedAt: now,
completedAt: null,
},
},
],
});
const firstRuntime = yield* manager.open({
threadId: firstThreadId,
providerSessionId,
modelSelection,
runtimePolicy,
});
const secondRuntime = yield* manager.open({
threadId: secondThreadId,
providerSessionId,
modelSelection,
runtimePolicy,
});
assert.strictEqual(firstRuntime, secondRuntime);
assert.equal((yield* Ref.get(state)).openCount, 1);
const resumeSecondThread = secondRuntime.resumeThread({
providerThread: secondProviderThread,
threadId: secondThreadId,
modelSelection,
runtimePolicy,
});
yield* resumeSecondThread;
yield* resumeSecondThread;
assert.equal((yield* Ref.get(state)).resumeCount, 1);
yield* secondRuntime.resumeThread({
providerThread: secondProviderThread,
threadId: secondThreadId,
modelSelection: { ...modelSelection, model: "gpt-5.4-mini" },
runtimePolicy,
});
assert.equal((yield* Ref.get(state)).resumeCount, 2);
yield* resumeSecondThread;
assert.equal((yield* Ref.get(state)).resumeCount, 3);
const subscribe = firstRuntime.subscribeEvents;
assert.isDefined(subscribe);
if (subscribe === undefined) return;
const firstSubscription = yield* subscribe;
const secondSubscription = yield* subscribe;
const queue = (yield* Ref.get(state)).eventQueues.get(String(providerSessionId));
assert.isDefined(queue);
yield* Queue.offer(queue!, {
type: "provider_session.updated",
driver: CODEX_DRIVER,
providerSession: firstRuntime.providerSession,
});
const received = yield* Effect.all([
firstSubscription.events.pipe(Stream.runHead),
secondSubscription.events.pipe(Stream.runHead),
]);
assert.isTrue(received.every(Option.isSome));
assert.isTrue(
received.every(
(event) => Option.isSome(event) && event.value.type === "provider_session.updated",
),
);
yield* manager.detach({ providerSessionId, threadId: secondThreadId });
yield* manager.open({
threadId: secondThreadId,
providerSessionId,
modelSelection,
runtimePolicy,
});
yield* resumeSecondThread;
assert.equal((yield* Ref.get(state)).resumeCount, 4);
yield* manager.detach({ providerSessionId, threadId: firstThreadId });
assert.isTrue(Option.isSome(yield* manager.get(providerSessionId)));
assert.equal((yield* Ref.get(state)).closeCount, 0);
assert.equal((yield* Ref.get(state)).interruptCount, 1);
yield* manager.detach({ providerSessionId, threadId: secondThreadId });
yield* TestClock.adjust("1 second");
yield* Effect.yieldNow;
assert.equal((yield* Ref.get(state)).closeCount, 1);
});
yield* effect.pipe(Effect.provide(makeTestLayer({ state, idleTimeoutMs: 1000 })));
}),
);
it.effect(
"ProviderSessionManagerV2 rejects a second thread when the provider runtime is exclusive",
() =>
Effect.gen(function* () {
const state = yield* Ref.make(emptyState);
const effect = Effect.gen(function* () {
const eventSink = yield* EventSinkV2;
const idAllocator = yield* IdAllocatorV2;
const manager = yield* ProviderSessionManagerV2;
const now = yield* DateTime.now;
const projectId = yield* idAllocator.allocate.project({
fixtureName: "provider-session-manager-exclusive-runtime",
});
const firstThreadId = yield* idAllocator.allocate.thread({
fixtureName: "provider-session-manager-exclusive-runtime-a",
projectId,
});
const secondThreadId = yield* idAllocator.allocate.thread({
fixtureName: "provider-session-manager-exclusive-runtime-b",
projectId,
});
const providerSessionId = yield* idAllocator.allocate.providerSession({
providerInstanceId: modelSelection.instanceId,
threadId: firstThreadId,
});
yield* eventSink.write({
events: [
yield* makeThreadCreatedEvent({ idAllocator, threadId: firstThreadId, now }),
yield* makeThreadCreatedEvent({ idAllocator, threadId: secondThreadId, now }),
],
});
yield* manager.open({
threadId: firstThreadId,
providerSessionId,
modelSelection,
runtimePolicy,
});
const error = yield* manager
.open({
threadId: secondThreadId,
providerSessionId,
modelSelection,
runtimePolicy,
})
.pipe(Effect.flip);
assert.equal(error._tag, "ProviderSessionOpenError");
assert.equal((yield* Ref.get(state)).openCount, 1);
});
yield* effect.pipe(
Effect.provide(
makeTestLayer({ state, idleTimeoutMs: 1000, capabilities: ExclusiveCapabilities }),
),
);
}),
);
it.todo(
"ProviderRuntimeRecoveryService restarts process_exited or transport_unavailable sessions with a bounded retry policy and resumes the native provider thread",
);
@@ -17,9 +17,11 @@ import * as Exit from "effect/Exit";
import * as Fiber from "effect/Fiber";
import * as Layer from "effect/Layer";
import * as Option from "effect/Option";
import * as Queue from "effect/Queue";
import * as Ref from "effect/Ref";
import * as Schema from "effect/Schema";
import * as Scope from "effect/Scope";
import * as Semaphore from "effect/Semaphore";
import * as Stream from "effect/Stream";
import * as McpProviderSession from "../mcp/McpProviderSession.ts";
@@ -27,7 +29,11 @@ import * as McpSessionRegistry from "../mcp/McpSessionRegistry.ts";
import { EventSinkV2 } from "./EventSink.ts";
import { IdAllocatorV2 } from "./IdAllocator.ts";
import {
ProviderAdapterEventStreamError,
ProviderAdapterV2RuntimePolicy,
type ProviderAdapterV2Error,
type ProviderAdapterV2Event,
type ProviderAdapterV2EventSubscription,
type ProviderAdapterV2SessionRuntime,
} from "./ProviderAdapter.ts";
import { ProviderAdapterRegistryV2 } from "./ProviderAdapterRegistry.ts";
@@ -149,6 +155,11 @@ export interface ProviderSessionManagerV2Shape {
readonly reason: ProviderSessionReleaseReason;
readonly detail?: string;
}) => Effect.Effect<void, ProviderSessionManagerV2Error>;
readonly detach: (input: {
readonly providerSessionId: ProviderSessionId;
readonly threadId: ThreadId;
readonly detail?: string;
}) => Effect.Effect<void, ProviderSessionManagerV2Error>;
}
export class ProviderSessionManagerV2 extends Context.Service<
@@ -158,8 +169,11 @@ export class ProviderSessionManagerV2 extends Context.Service<
interface LiveSessionEntry {
readonly attachedThreadIds: ReadonlySet<ThreadId>;
readonly loadedProviderThreadKeyByThread: ReadonlyMap<ThreadId, string>;
readonly supportsMultipleProviderThreads: boolean;
readonly runtime: ProviderAdapterV2SessionRuntime;
readonly exposedRuntime: ProviderAdapterV2SessionRuntime;
readonly eventSubscribers: Ref.Ref<ReadonlyMap<number, Queue.Queue<ProviderSessionEventSignal>>>;
readonly scope: Scope.Closeable;
readonly idleGeneration: number;
readonly busyCount: number;
@@ -167,6 +181,13 @@ interface LiveSessionEntry {
readonly idleFiber: Fiber.Fiber<void, never> | null;
}
type ProviderSessionEventSignal =
| { readonly type: "event"; readonly event: ProviderAdapterV2Event }
| {
readonly type: "failure";
readonly cause: Cause.Cause<ProviderAdapterV2Error>;
};
export interface ProviderSessionManagerV2LayerOptions {
readonly idleTimeoutMs?: number;
}
@@ -187,6 +208,29 @@ function sessionKey(providerSessionId: ProviderSessionId): string {
return String(providerSessionId);
}
function providerThreadRuntimeKey(
providerThread: Parameters<ProviderAdapterV2SessionRuntime["resumeThread"]>[0]["providerThread"],
): string {
const nativeThreadRef = providerThread.nativeThreadRef;
return nativeThreadRef === null
? String(providerThread.id)
: `${nativeThreadRef.driver}:${nativeThreadRef.nativeId}`;
}
function providerThreadLoadKey(input: {
readonly providerThread: Parameters<
ProviderAdapterV2SessionRuntime["resumeThread"]
>[0]["providerThread"];
readonly modelSelection?: ModelSelection;
readonly runtimePolicy?: ProviderAdapterV2RuntimePolicy;
}): string {
return JSON.stringify({
providerThread: providerThreadRuntimeKey(input.providerThread),
modelSelection: input.modelSelection ?? null,
runtimePolicy: input.runtimePolicy ?? null,
});
}
export const layerWithOptions = (
options: ProviderSessionManagerV2LayerOptions = {},
): Layer.Layer<
@@ -203,6 +247,8 @@ export const layerWithOptions = (
const projectionStore = yield* ProjectionStoreV2;
const layerScope = yield* Effect.scope;
const sessions = yield* Ref.make(new Map<string, LiveSessionEntry>());
const nextSubscriberId = yield* Ref.make(0);
const openSemaphore = yield* Semaphore.make(1);
const idleTimeoutMs = Math.max(1, options.idleTimeoutMs ?? DEFAULT_IDLE_TIMEOUT_MS);
const prepareMcpSession = (threadId: ThreadId, providerInstanceId: ProviderInstanceId) =>
McpSessionRegistry.issueActiveMcpCredential({
@@ -220,9 +266,64 @@ export const layerWithOptions = (
Effect.tap(() => Effect.sync(() => McpProviderSession.clearMcpProviderSession(threadId))),
);
const publishToSubscribers = (
subscribers: Ref.Ref<ReadonlyMap<number, Queue.Queue<ProviderSessionEventSignal>>>,
signal: ProviderSessionEventSignal,
) =>
Ref.get(subscribers).pipe(
Effect.flatMap((current) =>
Effect.forEach(current.values(), (queue) => Queue.offer(queue, signal), {
discard: true,
}),
),
);
const failSubscribers = (entry: LiveSessionEntry, detail: string) =>
Effect.gen(function* () {
const error = new ProviderAdapterEventStreamError({
driver: entry.runtime.driver,
providerSessionId: entry.runtime.providerSessionId,
cause: detail,
});
yield* publishToSubscribers(entry.eventSubscribers, {
type: "failure",
cause: Cause.fail(error),
});
yield* Ref.set(entry.eventSubscribers, new Map());
});
const cancelIdleFiber = (fiber: Fiber.Fiber<void, never> | null) =>
fiber === null ? Effect.void : Fiber.interrupt(fiber).pipe(Effect.ignore);
const writeProviderSessionEvents = (input: {
readonly runtime: ProviderAdapterV2SessionRuntime;
readonly threadIds: Iterable<ThreadId>;
readonly type: "provider-session.attached" | "provider-session.updated";
readonly payload: OrchestrationV2ProviderSession;
}) =>
Effect.gen(function* () {
const now = yield* DateTime.now;
const events = yield* Effect.forEach(input.threadIds, (threadId) =>
Effect.gen(function* () {
return {
id: yield* idAllocator.allocate.event({
threadId,
providerSessionId: input.runtime.providerSessionId,
}),
type: input.type,
threadId,
driver: input.runtime.driver,
providerInstanceId: input.runtime.instanceId,
occurredAt: now,
payload: input.payload,
} satisfies OrchestrationV2DomainEvent;
}),
);
if (events.length > 0) {
yield* eventSink.write({ events });
}
});
const writeReleasedSessionEvents = (input: {
readonly entry: LiveSessionEntry;
readonly reason: ProviderSessionReleaseReason;
@@ -239,24 +340,12 @@ export const layerWithOptions = (
? (input.detail ?? "Provider runtime failed.")
: null,
};
const events = yield* Effect.forEach(
Array.from(input.entry.attachedThreadIds),
(threadId) =>
Effect.gen(function* () {
return {
id: yield* idAllocator.allocate.event({
threadId,
providerSessionId: input.entry.runtime.providerSessionId,
}),
type: "provider-session.updated",
threadId,
driver: input.entry.runtime.driver,
occurredAt: now,
payload,
} satisfies OrchestrationV2DomainEvent;
}),
);
yield* eventSink.write({ events });
yield* writeProviderSessionEvents({
runtime: input.entry.runtime,
threadIds: input.entry.attachedThreadIds,
type: "provider-session.updated",
payload,
});
});
const writeReleasedRuntimeRequestEvents = (input: {
@@ -380,6 +469,10 @@ export const layerWithOptions = (
if (input.cancelIdleFiber !== false) {
yield* cancelIdleFiber(entry.value.idleFiber);
}
yield* failSubscribers(
entry.value,
input.detail ?? `Provider session released: ${input.reason}.`,
);
const closeExit = yield* Effect.exit(Scope.close(entry.value.scope, Exit.void));
yield* writeReleasedSessionEvents({
entry: entry.value,
@@ -511,20 +604,103 @@ export const layerWithOptions = (
}) =>
withActivityError(
input.providerSessionId,
Ref.update(sessions, (current) => {
Ref.modify(sessions, (current) => {
const entry = current.get(sessionKey(input.providerSessionId));
if (entry === undefined || entry.attachedThreadIds.has(input.threadId)) {
return current;
return [false, current] as const;
}
const updated = new Map(current);
updated.set(sessionKey(input.providerSessionId), {
...entry,
attachedThreadIds: new Set([...entry.attachedThreadIds, input.threadId]),
});
return updated;
return [true, updated] as const;
}),
);
const removeThreadAttachment = (input: {
readonly providerSessionId: ProviderSessionId;
readonly threadId: ThreadId;
}) =>
Ref.update(sessions, (current) => {
const key = sessionKey(input.providerSessionId);
const entry = current.get(key);
if (entry === undefined || !entry.attachedThreadIds.has(input.threadId)) {
return current;
}
const attachedThreadIds = new Set(entry.attachedThreadIds);
attachedThreadIds.delete(input.threadId);
const loadedProviderThreadKeyByThread = new Map(entry.loadedProviderThreadKeyByThread);
loadedProviderThreadKeyByThread.delete(input.threadId);
const updated = new Map(current);
updated.set(key, {
...entry,
attachedThreadIds,
loadedProviderThreadKeyByThread,
});
return updated;
});
const isProviderThreadLoaded = (input: {
readonly providerSessionId: ProviderSessionId;
readonly threadId: ThreadId;
readonly providerThreadKey: string;
}) =>
Ref.get(sessions).pipe(
Effect.map(
(current) =>
current
.get(sessionKey(input.providerSessionId))
?.loadedProviderThreadKeyByThread.get(input.threadId) === input.providerThreadKey,
),
);
const markProviderThreadLoaded = (input: {
readonly providerSessionId: ProviderSessionId;
readonly threadId: ThreadId;
readonly providerThreadKey: string;
}) =>
Ref.update(sessions, (current) => {
const key = sessionKey(input.providerSessionId);
const entry = current.get(key);
if (entry === undefined) {
return current;
}
const loadedProviderThreadKeyByThread = new Map(entry.loadedProviderThreadKeyByThread);
loadedProviderThreadKeyByThread.set(input.threadId, input.providerThreadKey);
const updated = new Map(current);
updated.set(key, { ...entry, loadedProviderThreadKeyByThread });
return updated;
});
const ensureThreadAttached = (input: {
readonly providerSessionId: ProviderSessionId;
readonly threadId: ThreadId;
readonly providerInstanceId: ProviderInstanceId;
}) =>
Effect.gen(function* () {
const attached = yield* attachThread(input);
if (attached) {
yield* prepareMcpSession(input.threadId, input.providerInstanceId);
const entry = (yield* Ref.get(sessions)).get(sessionKey(input.providerSessionId));
if (entry !== undefined) {
yield* withActivityError(
input.providerSessionId,
writeProviderSessionEvents({
runtime: entry.runtime,
threadIds: [input.threadId],
type: "provider-session.attached",
payload: entry.runtime.providerSession,
}),
);
}
}
}).pipe(
Effect.tapError(() =>
removeThreadAttachment(input).pipe(Effect.andThen(clearMcpSession(input.threadId))),
),
);
const markBusy = (providerSessionId: ProviderSessionId) =>
withActivityError(
providerSessionId,
@@ -585,47 +761,147 @@ export const layerWithOptions = (
),
);
const makeEventSubscription = (
subscribers: Ref.Ref<ReadonlyMap<number, Queue.Queue<ProviderSessionEventSignal>>>,
): Effect.Effect<ProviderAdapterV2EventSubscription> =>
Effect.gen(function* () {
const queue = yield* Queue.unbounded<ProviderSessionEventSignal>();
const subscriberId = yield* Ref.getAndUpdate(nextSubscriberId, (value) => value + 1);
yield* Ref.update(subscribers, (current) => {
const updated = new Map(current);
updated.set(subscriberId, queue);
return updated;
});
const close = Ref.modify(subscribers, (current) => {
if (!current.has(subscriberId)) {
return [false, current] as const;
}
const updated = new Map(current);
updated.delete(subscriberId);
return [true, updated] as const;
}).pipe(Effect.flatMap((removed) => (removed ? Queue.shutdown(queue) : Effect.void)));
const events = Stream.fromQueue(queue).pipe(
Stream.mapEffect((signal) =>
signal.type === "event"
? Effect.succeed(signal.event)
: Effect.failCause(signal.cause),
),
Stream.ensuring(close),
);
return { events, close } satisfies ProviderAdapterV2EventSubscription;
});
const decorateRuntime = (
runtime: ProviderAdapterV2SessionRuntime,
eventSubscribers: Ref.Ref<ReadonlyMap<number, Queue.Queue<ProviderSessionEventSignal>>>,
): ProviderAdapterV2SessionRuntime => {
const providerSessionId = runtime.providerSessionId;
const subscribeEvents = makeEventSubscription(eventSubscribers);
return {
...runtime,
events: runtime.events.pipe(
Stream.tap((event) =>
event.type === "turn.terminal"
? observeActivity(providerSessionId, markIdle(providerSessionId))
: observeActivity(providerSessionId, touchActivity(providerSessionId)),
),
Stream.catchCause((cause) =>
Stream.fromEffect(
releaseEntry({
providerSessionId,
reason: "runtime_error",
detail: Cause.pretty(cause),
}).pipe(Effect.ignore, Effect.andThen(Effect.failCause(cause))),
),
),
subscribeEvents,
events: Stream.unwrap(
subscribeEvents.pipe(Effect.map((subscription) => subscription.events)),
),
ensureThread: (input) =>
observeActivity(
providerSessionId,
attachThread({ providerSessionId, threadId: input.threadId }),
).pipe(Effect.andThen(runtime.ensureThread(input))),
resumeThread: (input) =>
input.providerThread.appThreadId === null
? runtime.resumeThread(input)
: observeActivity(
ensureThreadAttached({
providerSessionId,
threadId: input.threadId,
providerInstanceId: runtime.instanceId,
}),
).pipe(
Effect.andThen(runtime.ensureThread(input)),
Effect.tap((providerThread) =>
markProviderThreadLoaded({
providerSessionId,
attachThread({
providerSessionId,
threadId: input.providerThread.appThreadId,
threadId: input.threadId,
providerThreadKey: providerThreadLoadKey({
providerThread,
modelSelection: input.modelSelection,
runtimePolicy: input.runtimePolicy,
}),
).pipe(Effect.andThen(runtime.resumeThread(input))),
}),
),
),
resumeThread: (input) => {
const threadId = input.threadId ?? input.providerThread.appThreadId;
if (threadId === null || threadId === undefined) {
return runtime.resumeThread(input);
}
const providerThreadKey = providerThreadLoadKey({
providerThread: input.providerThread,
...(input.modelSelection === undefined
? {}
: { modelSelection: input.modelSelection }),
...(input.runtimePolicy === undefined ? {} : { runtimePolicy: input.runtimePolicy }),
});
return observeActivity(
providerSessionId,
ensureThreadAttached({
providerSessionId,
threadId,
providerInstanceId: runtime.instanceId,
}),
).pipe(
Effect.andThen(
isProviderThreadLoaded({ providerSessionId, threadId, providerThreadKey }),
),
Effect.flatMap((loaded) =>
loaded ? Effect.succeed(input.providerThread) : runtime.resumeThread(input),
),
Effect.tap((providerThread) =>
markProviderThreadLoaded({
providerSessionId,
threadId,
providerThreadKey: providerThreadLoadKey({
providerThread,
...(input.modelSelection === undefined
? {}
: { modelSelection: input.modelSelection }),
...(input.runtimePolicy === undefined
? {}
: { runtimePolicy: input.runtimePolicy }),
}),
}),
),
);
},
forkThread: (input) =>
observeActivity(
providerSessionId,
ensureThreadAttached({
providerSessionId,
threadId: input.targetThreadId,
providerInstanceId: runtime.instanceId,
}),
).pipe(
Effect.andThen(runtime.forkThread(input)),
Effect.tap((providerThread) =>
markProviderThreadLoaded({
providerSessionId,
threadId: input.targetThreadId,
providerThreadKey: providerThreadLoadKey({
providerThread,
...(input.modelSelection === undefined
? {}
: { modelSelection: input.modelSelection }),
...(input.runtimePolicy === undefined
? {}
: { runtimePolicy: input.runtimePolicy }),
}),
}),
),
),
startTurn: (input) =>
observeActivity(
providerSessionId,
attachThread({ providerSessionId, threadId: input.threadId }),
ensureThreadAttached({
providerSessionId,
threadId: input.threadId,
providerInstanceId: runtime.instanceId,
}),
).pipe(
Effect.andThen(observeActivity(providerSessionId, markBusy(providerSessionId))),
Effect.andThen(runtime.startTurn(input)),
@@ -650,6 +926,84 @@ export const layerWithOptions = (
};
};
const persistProviderSessionUpdate = (
entry: LiveSessionEntry,
event: Extract<ProviderAdapterV2Event, { readonly type: "provider_session.updated" }>,
) =>
Effect.gen(function* () {
const current = (yield* Ref.get(sessions)).get(
sessionKey(entry.runtime.providerSessionId),
);
if (current?.runtime !== entry.runtime) {
return;
}
yield* writeProviderSessionEvents({
runtime: entry.runtime,
threadIds: current.attachedThreadIds,
type: "provider-session.updated",
payload: event.providerSession,
});
}).pipe(
Effect.catchCause((cause) =>
Effect.logWarning("orchestration-v2.driver-session.status-persist-failed", {
providerSessionId: entry.runtime.providerSessionId,
cause,
}),
),
);
const startEventPump = (entry: LiveSessionEntry) =>
entry.runtime.events.pipe(
Stream.runForEach((event) =>
observeActivity(
entry.runtime.providerSessionId,
event.type === "turn.terminal"
? markIdle(entry.runtime.providerSessionId)
: touchActivity(entry.runtime.providerSessionId),
).pipe(
Effect.andThen(
event.type === "provider_session.updated"
? persistProviderSessionUpdate(entry, event)
: Effect.void,
),
Effect.andThen(
publishToSubscribers(entry.eventSubscribers, { type: "event", event }),
),
),
),
Effect.exit,
Effect.flatMap((exit) =>
Effect.gen(function* () {
const current = (yield* Ref.get(sessions)).get(
sessionKey(entry.runtime.providerSessionId),
);
if (current?.runtime !== entry.runtime) {
return;
}
const cause = Exit.isFailure(exit)
? exit.cause
: Cause.fail(
new ProviderAdapterEventStreamError({
driver: entry.runtime.driver,
providerSessionId: entry.runtime.providerSessionId,
cause: "Provider event stream ended unexpectedly.",
}),
);
yield* publishToSubscribers(entry.eventSubscribers, {
type: "failure",
cause,
});
yield* Ref.set(entry.eventSubscribers, new Map());
yield* releaseEntry({
providerSessionId: entry.runtime.providerSessionId,
reason: "runtime_error",
detail: Cause.pretty(cause),
}).pipe(Effect.ignore);
}),
),
Effect.forkIn(layerScope),
);
yield* Effect.addFinalizer(() =>
Effect.gen(function* () {
const activeSessions = [...(yield* Ref.get(sessions)).values()];
@@ -674,48 +1028,31 @@ export const layerWithOptions = (
return ProviderSessionManagerV2.of({
open: (input) =>
Effect.gen(function* () {
const key = sessionKey(input.providerSessionId);
const existing = (yield* Ref.get(sessions)).get(key);
if (existing !== undefined) {
yield* attachThread({
providerSessionId: input.providerSessionId,
threadId: input.threadId,
});
yield* touchActivity(input.providerSessionId);
return existing.exposedRuntime;
}
const adapter = yield* registry.get(input.modelSelection.provider).pipe(
Effect.mapError(
(cause) =>
new ProviderSessionOpenError({
provider: input.modelSelection.provider,
openSemaphore.withPermit(
Effect.gen(function* () {
const key = sessionKey(input.providerSessionId);
const existing = (yield* Ref.get(sessions)).get(key);
if (existing !== undefined) {
if (
!existing.attachedThreadIds.has(input.threadId) &&
!existing.supportsMultipleProviderThreads
) {
return yield* new ProviderSessionOpenError({
instanceId: input.modelSelection.instanceId,
providerSessionId: input.providerSessionId,
cause,
}),
),
);
yield* prepareMcpSession(input.threadId, input.modelSelection.instanceId);
const sessionScope = yield* Scope.make();
const runtime = yield* adapter
.openSession({
threadId: input.threadId,
providerSessionId: input.providerSessionId,
modelSelection: input.modelSelection,
runtimePolicy: input.runtimePolicy,
...(input.resumeFromSession === undefined
? {}
: { resumeFromSession: input.resumeFromSession }),
})
.pipe(
Effect.provideService(Scope.Scope, sessionScope),
Effect.tapError(() =>
Scope.close(sessionScope, Exit.void).pipe(
Effect.ignore,
Effect.andThen(clearMcpSession(input.threadId)),
),
),
cause: `Provider ${existing.runtime.driver} does not support attaching multiple app threads to one session.`,
});
}
yield* ensureThreadAttached({
providerSessionId: input.providerSessionId,
threadId: input.threadId,
providerInstanceId: existing.runtime.instanceId,
});
yield* touchActivity(input.providerSessionId);
return existing.exposedRuntime;
}
const adapter = yield* registry.get(input.modelSelection.instanceId).pipe(
Effect.mapError(
(cause) =>
new ProviderSessionOpenError({
@@ -725,25 +1062,82 @@ export const layerWithOptions = (
}),
),
);
const exposedRuntime = decorateRuntime(runtime);
const now = yield* Clock.currentTimeMillis;
yield* Ref.update(sessions, (current) => {
const updated = new Map(current);
updated.set(key, {
yield* prepareMcpSession(input.threadId, input.modelSelection.instanceId);
const sessionScope = yield* Scope.make();
const runtime = yield* adapter
.openSession({
threadId: input.threadId,
providerSessionId: input.providerSessionId,
modelSelection: input.modelSelection,
runtimePolicy: input.runtimePolicy,
...(input.resumeFromSession === undefined
? {}
: { resumeFromSession: input.resumeFromSession }),
})
.pipe(
Effect.provideService(Scope.Scope, sessionScope),
Effect.tapError(() =>
Scope.close(sessionScope, Exit.void).pipe(
Effect.ignore,
Effect.andThen(clearMcpSession(input.threadId)),
),
),
Effect.mapError(
(cause) =>
new ProviderSessionOpenError({
instanceId: input.modelSelection.instanceId,
providerSessionId: input.providerSessionId,
cause,
}),
),
);
const eventSubscribers = yield* Ref.make<
ReadonlyMap<number, Queue.Queue<ProviderSessionEventSignal>>
>(new Map());
const exposedRuntime = decorateRuntime(runtime, eventSubscribers);
const now = yield* Clock.currentTimeMillis;
const entry: LiveSessionEntry = {
attachedThreadIds: new Set([input.threadId]),
loadedProviderThreadKeyByThread: new Map(),
supportsMultipleProviderThreads:
runtime.providerSession.capabilities.sessions
.supportsMultipleProviderThreadsPerSession,
runtime,
exposedRuntime,
eventSubscribers,
scope: sessionScope,
idleGeneration: 0,
busyCount: 0,
lastActivityAtMs: now,
idleFiber: null,
};
yield* Ref.update(sessions, (current) => {
const updated = new Map(current);
updated.set(key, entry);
return updated;
});
return updated;
});
yield* scheduleIdleRelease(input.providerSessionId);
return exposedRuntime;
}),
yield* withActivityError(
input.providerSessionId,
writeProviderSessionEvents({
runtime,
threadIds: [input.threadId],
type: "provider-session.attached",
payload: runtime.providerSession,
}),
).pipe(
Effect.tapError(() =>
releaseEntry({
providerSessionId: input.providerSessionId,
reason: "runtime_error",
detail: "Failed to persist the provider-session attachment.",
}).pipe(Effect.ignore),
),
);
yield* startEventPump(entry);
yield* scheduleIdleRelease(input.providerSessionId);
return exposedRuntime;
}),
),
get: (providerSessionId) =>
Effect.gen(function* () {
const entry = (yield* Ref.get(sessions)).get(sessionKey(providerSessionId));
@@ -772,6 +1166,95 @@ export const layerWithOptions = (
),
),
release: releaseEntry,
detach: (input) =>
Effect.gen(function* () {
const key = sessionKey(input.providerSessionId);
const currentEntry = (yield* Ref.get(sessions)).get(key);
if (currentEntry?.supportsMultipleProviderThreads === true) {
const projection = yield* Effect.option(
projectionStore.getThreadProjection(input.threadId),
);
if (Option.isSome(projection)) {
const providerThreads = new Map(
projection.value.providerThreads
.filter((thread) => thread.providerSessionId === input.providerSessionId)
.map((thread) => [thread.id, thread] as const),
);
const activeTurns = projection.value.providerTurns.filter(
(turn) => turn.status === "running" && providerThreads.has(turn.providerThreadId),
);
yield* Effect.forEach(
activeTurns,
(turn) =>
currentEntry.exposedRuntime
.interruptTurn({
providerThread: providerThreads.get(turn.providerThreadId)!,
providerTurnId: turn.id,
})
.pipe(
Effect.catchCause((cause) =>
Effect.logWarning(
"orchestration-v2.driver-session.detach-interrupt-failed",
{
providerSessionId: input.providerSessionId,
threadId: input.threadId,
providerTurnId: turn.id,
cause,
},
),
),
),
{ concurrency: 1, discard: true },
);
}
}
const detached = yield* Ref.modify(sessions, (current) => {
const entry = current.get(key);
if (entry === undefined || !entry.attachedThreadIds.has(input.threadId)) {
return [Option.none<LiveSessionEntry>(), current] as const;
}
const attachedThreadIds = new Set(entry.attachedThreadIds);
attachedThreadIds.delete(input.threadId);
const loadedProviderThreadKeyByThread = new Map(
entry.loadedProviderThreadKeyByThread,
);
loadedProviderThreadKeyByThread.delete(input.threadId);
const updatedEntry = {
...entry,
attachedThreadIds,
loadedProviderThreadKeyByThread,
};
const updated = new Map(current);
updated.set(key, updatedEntry);
return [Option.some(updatedEntry), updated] as const;
});
yield* clearMcpSession(input.threadId);
if (Option.isNone(detached)) {
return;
}
if (
detached.value.attachedThreadIds.size === 0 &&
!detached.value.supportsMultipleProviderThreads
) {
yield* releaseEntry({
providerSessionId: input.providerSessionId,
reason: "manual_shutdown",
...(input.detail === undefined ? {} : { detail: input.detail }),
});
return;
}
yield* scheduleIdleRelease(input.providerSessionId);
}).pipe(
Effect.catchCause((cause) =>
Effect.fail(
new ProviderSessionReleaseError({
providerSessionId: input.providerSessionId,
reason: "manual_shutdown",
cause,
}),
),
),
),
} satisfies ProviderSessionManagerV2Shape);
}),
);
@@ -12,7 +12,6 @@ import * as Context from "effect/Context";
import * as DateTime from "effect/DateTime";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as Option from "effect/Option";
import * as Schema from "effect/Schema";
import { EventSinkV2 } from "./EventSink.ts";
@@ -118,7 +117,6 @@ export const layer: Layer.Layer<
const existingSessionProjection = projection.providerSessions.find(
(candidate) => candidate.id === providerSessionId,
);
const activeSession = yield* providerSessions.get(providerSessionId);
const session = yield* providerSessions.open({
threadId: projection.thread.id,
providerSessionId,
@@ -157,6 +155,8 @@ export const layer: Layer.Layer<
sourceProviderThread,
sourceProviderTurns: sourceProjection.providerTurns,
targetThreadId: projection.thread.id,
modelSelection: run.modelSelection,
runtimePolicy: resolvedRuntimePolicy,
...(sourceProviderTurn === undefined ? {} : { providerTurnId: sourceProviderTurn.id }),
});
}
@@ -167,9 +167,12 @@ export const layer: Layer.Layer<
runtimePolicy: resolvedRuntimePolicy,
providerSessionId,
})
: Option.isSome(activeSession)
? providerThread
: yield* session.resumeThread({ providerThread });
: yield* session.resumeThread({
providerThread,
threadId: projection.thread.id,
modelSelection: run.modelSelection,
runtimePolicy: resolvedRuntimePolicy,
});
});
const now = yield* DateTime.now;
const runningProviderThread: OrchestrationV2ProviderThread = {
@@ -294,6 +297,12 @@ export const layer: Layer.Layer<
providerThread: runningProviderThread,
attempt: runningAttempt,
attemptId: attempt.id,
relatedThreadIds: projection.subagents.flatMap((subagent) =>
subagent.childThreadId === null ? [] : [subagent.childThreadId],
),
relatedProviderThreadIds: projection.subagents.flatMap((subagent) =>
subagent.providerThreadId === null ? [] : [subagent.providerThreadId],
),
providerTurnOrdinal:
Math.max(
0,
@@ -0,0 +1,137 @@
import { assert, it } from "@effect/vitest";
import {
MessageId,
NodeId,
ProviderDriverKind,
ProviderThreadId,
ProviderTurnId,
RunAttemptId,
RunId,
ThreadId,
} from "@t3tools/contracts";
import * as DateTime from "effect/DateTime";
import * as Effect from "effect/Effect";
import type { ProviderAdapterV2Event } from "./ProviderAdapter.ts";
import {
makeProviderEventRoutingState,
type ProviderEventRouteIdentity,
routeProviderEvent,
} from "./RunExecutionService.ts";
const driver = ProviderDriverKind.make("codex");
it.effect("routes shared-runtime events only to their owning root run", () =>
Effect.gen(function* () {
const now = yield* DateTime.now;
const first: ProviderEventRouteIdentity = {
threadId: ThreadId.make("thread:shared-runtime:first"),
runId: RunId.make("run:shared-runtime:first"),
attemptId: RunAttemptId.make("attempt:shared-runtime:first"),
providerThreadId: ProviderThreadId.make("provider-thread:shared-runtime:first"),
};
const second: ProviderEventRouteIdentity = {
threadId: ThreadId.make("thread:shared-runtime:second"),
runId: RunId.make("run:shared-runtime:second"),
attemptId: RunAttemptId.make("attempt:shared-runtime:second"),
providerThreadId: ProviderThreadId.make("provider-thread:shared-runtime:second"),
};
const firstTurnId = ProviderTurnId.make("provider-turn:shared-runtime:first");
const turnEvent: ProviderAdapterV2Event = {
type: "provider_turn.updated",
driver,
threadId: first.threadId,
providerTurn: {
id: firstTurnId,
providerThreadId: first.providerThreadId,
nodeId: NodeId.make("node:shared-runtime:first"),
runAttemptId: first.attemptId,
nativeTurnRef: null,
ordinal: 1,
status: "running",
startedAt: now,
completedAt: null,
},
};
const messageEvent: ProviderAdapterV2Event = {
type: "message.updated",
driver,
message: {
createdBy: "agent",
creationSource: "provider",
id: MessageId.make("message:shared-runtime:first"),
threadId: first.threadId,
runId: first.runId,
nodeId: NodeId.make("node:shared-runtime:first"),
role: "assistant",
text: "first only",
attachments: [],
streaming: false,
createdAt: now,
updatedAt: now,
},
};
const terminalEvent: ProviderAdapterV2Event = {
type: "turn.terminal",
driver,
providerTurnId: firstTurnId,
status: "completed",
};
const firstInitial = makeProviderEventRoutingState({
identity: first,
providerTurnId: null,
});
const secondInitial = makeProviderEventRoutingState({
identity: second,
providerTurnId: null,
});
const [firstTurnAccepted, firstAfterTurn] = routeProviderEvent(turnEvent, first, firstInitial);
const [secondTurnAccepted, secondAfterTurn] = routeProviderEvent(
turnEvent,
second,
secondInitial,
);
assert.isTrue(firstTurnAccepted);
assert.isFalse(secondTurnAccepted);
assert.isTrue(routeProviderEvent(messageEvent, first, firstAfterTurn)[0]);
assert.isFalse(routeProviderEvent(messageEvent, second, secondAfterTurn)[0]);
assert.isTrue(routeProviderEvent(terminalEvent, first, firstAfterTurn)[0]);
assert.isFalse(routeProviderEvent(terminalEvent, second, secondAfterTurn)[0]);
}),
);
it("does not route a superseded attempt through a reused provider thread", () => {
const threadId = ThreadId.make("thread:shared-runtime:restart");
const providerThreadId = ProviderThreadId.make("provider-thread:shared-runtime:restart");
const oldAttempt: ProviderEventRouteIdentity = {
threadId,
runId: RunId.make("run:shared-runtime:restart"),
attemptId: RunAttemptId.make("attempt:shared-runtime:restart:old"),
providerThreadId,
};
const newAttempt: ProviderEventRouteIdentity = {
...oldAttempt,
attemptId: RunAttemptId.make("attempt:shared-runtime:restart:new"),
};
const oldTurnEvent: ProviderAdapterV2Event = {
type: "provider_turn.updated",
driver,
threadId,
providerTurn: {
id: ProviderTurnId.make("provider-turn:shared-runtime:restart:old"),
providerThreadId,
nodeId: NodeId.make("node:shared-runtime:restart:old"),
runAttemptId: oldAttempt.attemptId,
nativeTurnRef: null,
ordinal: 1,
status: "interrupted",
startedAt: null,
completedAt: null,
},
};
const newState = makeProviderEventRoutingState({ identity: newAttempt, providerTurnId: null });
assert.isFalse(routeProviderEvent(oldTurnEvent, newAttempt, newState)[0]);
});
@@ -9,7 +9,10 @@ import {
type OrchestrationV2RunAttempt,
type OrchestrationV2TurnItem,
type ProviderSessionId,
type ProviderThreadId,
type ProviderTurnId,
type RunAttemptId,
type ThreadId,
} from "@t3tools/contracts";
import * as Context from "effect/Context";
import * as DateTime from "effect/DateTime";
@@ -32,6 +35,127 @@ import type {
} from "./ProviderAdapter.ts";
import { ProviderEventIngestorV2 } from "./ProviderEventIngestor.ts";
export interface ProviderEventRoutingState {
readonly ownedThreadIds: ReadonlySet<ThreadId>;
readonly ownedProviderThreadIds: ReadonlySet<ProviderThreadId>;
readonly ownedProviderTurnIds: ReadonlySet<ProviderTurnId>;
readonly rootProviderTurnId: ProviderTurnId | null;
}
export interface ProviderEventRouteIdentity {
readonly threadId: ThreadId;
readonly runId: OrchestrationV2Run["id"];
readonly attemptId: RunAttemptId;
readonly providerThreadId: ProviderThreadId;
}
export function makeProviderEventRoutingState(input: {
readonly identity: ProviderEventRouteIdentity;
readonly providerTurnId: ProviderTurnId | null;
readonly relatedThreadIds?: ReadonlyArray<ThreadId>;
readonly relatedProviderThreadIds?: ReadonlyArray<ProviderThreadId>;
}): ProviderEventRoutingState {
return {
ownedThreadIds: new Set([input.identity.threadId, ...(input.relatedThreadIds ?? [])]),
ownedProviderThreadIds: new Set([
input.identity.providerThreadId,
...(input.relatedProviderThreadIds ?? []),
]),
ownedProviderTurnIds:
input.providerTurnId === null ? new Set() : new Set([input.providerTurnId]),
rootProviderTurnId: input.providerTurnId,
};
}
export function routeProviderEvent(
event: ProviderAdapterV2Event,
input: ProviderEventRouteIdentity,
state: ProviderEventRoutingState,
): readonly [boolean, ProviderEventRoutingState] {
const ownsThread = (threadId: ThreadId): boolean => state.ownedThreadIds.has(threadId);
const ownsChildThread = (threadId: ThreadId): boolean =>
threadId !== input.threadId && ownsThread(threadId);
const ownsRun = (runId: string | null): boolean => runId === input.runId;
const addProviderThread = (providerThreadId: ProviderThreadId): ProviderEventRoutingState => ({
...state,
ownedProviderThreadIds: new Set([...state.ownedProviderThreadIds, providerThreadId]),
});
const addProviderTurn = (
providerTurnId: ProviderTurnId,
root: boolean,
): ProviderEventRoutingState => ({
...state,
ownedProviderTurnIds: new Set([...state.ownedProviderTurnIds, providerTurnId]),
rootProviderTurnId: root ? providerTurnId : state.rootProviderTurnId,
});
switch (event.type) {
case "provider_session.updated":
// The session manager persists process-wide status once for every
// attached app thread before broadcasting the adapter event.
return [false, state];
case "app_thread.created": {
if (event.appThread.id === input.threadId) {
return [true, state];
}
const isOwnedSubagent =
event.appThread.lineage.relationshipToParent === "subagent" &&
event.appThread.lineage.parentThreadId !== null &&
ownsThread(event.appThread.lineage.parentThreadId);
if (!isOwnedSubagent) {
return [false, state];
}
return [
true,
{
...state,
ownedThreadIds: new Set([...state.ownedThreadIds, event.appThread.id]),
},
];
}
case "provider_thread.updated": {
const belongs =
state.ownedProviderThreadIds.has(event.providerThread.id) ||
(event.providerThread.appThreadId !== null && ownsThread(event.providerThread.appThreadId));
return belongs ? [true, addProviderThread(event.providerThread.id)] : [false, state];
}
case "provider_turn.updated": {
const isRoot = event.providerTurn.runAttemptId === input.attemptId;
const belongs =
isRoot ||
(event.providerTurn.providerThreadId !== input.providerThreadId &&
state.ownedProviderThreadIds.has(event.providerTurn.providerThreadId)) ||
state.ownedProviderTurnIds.has(event.providerTurn.id) ||
(event.threadId !== undefined && ownsChildThread(event.threadId));
return belongs ? [true, addProviderTurn(event.providerTurn.id, isRoot)] : [false, state];
}
case "node.updated": {
const belongs = ownsRun(event.node.runId) || ownsChildThread(event.node.threadId);
if (!belongs || event.node.providerThreadId === null) {
return [belongs, state];
}
return [true, addProviderThread(event.node.providerThreadId)];
}
case "subagent.updated":
return [ownsRun(event.subagent.runId) || ownsChildThread(event.subagent.threadId), state];
case "message.updated":
return [ownsRun(event.message.runId) || ownsChildThread(event.message.threadId), state];
case "turn_item.updated":
return [ownsRun(event.turnItem.runId) || ownsChildThread(event.turnItem.threadId), state];
case "plan.updated":
return [ownsRun(event.plan.runId) || ownsChildThread(event.plan.threadId), state];
case "runtime_request.updated":
return [
(event.threadId !== undefined && ownsChildThread(event.threadId)) ||
(event.runtimeRequest.providerTurnId !== null &&
state.ownedProviderTurnIds.has(event.runtimeRequest.providerTurnId)),
state,
];
case "turn.terminal":
return [event.providerTurnId === state.rootProviderTurnId, state];
}
}
/**
* ERRORS
*/
@@ -81,6 +205,8 @@ export interface RunExecutionServiceV2StartRootRunInput {
readonly attempt: OrchestrationV2RunAttempt;
readonly attemptId: RunAttemptId;
readonly providerTurnOrdinal: number;
readonly relatedThreadIds?: ReadonlyArray<ThreadId>;
readonly relatedProviderThreadIds?: ReadonlyArray<ProviderThreadId>;
readonly shouldFinalizeRun?: () => Effect.Effect<boolean, never>;
readonly message: ProviderAdapterV2TurnMessage;
readonly modelSelection: ModelSelection;
@@ -309,12 +435,52 @@ export const layer: Layer.Layer<
}),
),
);
yield* checkpointService
.captureBaseline({
scope: input.checkpointScope,
ordinalWithinScope: Math.max(0, input.run.ordinal - 1),
})
.pipe(
Effect.mapError(
(cause) =>
new RunExecutionStartError({
commandId: input.commandId,
runId: input.run.id,
cause,
}),
),
);
const terminalStatus = yield* Ref.make<Extract<
OrchestrationV2Run["status"],
"completed" | "interrupted" | "failed" | "cancelled"
> | null>(null);
const latestProviderThread = yield* Ref.make(input.providerThread);
const providerEventFiber = yield* input.session.events.pipe(
const routeIdentity: ProviderEventRouteIdentity = {
threadId: input.run.threadId,
runId: input.run.id,
attemptId: input.attempt.id,
providerThreadId: input.providerThread.id,
};
const eventRouting = yield* Ref.make<ProviderEventRoutingState>(
makeProviderEventRoutingState({
identity: routeIdentity,
providerTurnId: input.attempt.providerTurnId,
...(input.relatedThreadIds === undefined
? {}
: { relatedThreadIds: input.relatedThreadIds }),
...(input.relatedProviderThreadIds === undefined
? {}
: { relatedProviderThreadIds: input.relatedProviderThreadIds }),
}),
);
const eventSubscription =
input.session.subscribeEvents === undefined
? { events: input.session.events, close: Effect.void }
: yield* input.session.subscribeEvents;
const providerEventFiber = yield* eventSubscription.events.pipe(
Stream.filterEffect((event) =>
Ref.modify(eventRouting, (state) => routeProviderEvent(event, routeIdentity, state)),
),
Stream.takeUntil((event) => event.type === "turn.terminal"),
Stream.runForEach((event) =>
Effect.gen(function* () {
@@ -391,25 +557,10 @@ export const layer: Layer.Layer<
),
),
),
Effect.ensuring(eventSubscription.close),
Effect.forkDetach,
);
yield* checkpointService
.captureBaseline({
scope: input.checkpointScope,
ordinalWithinScope: Math.max(0, input.run.ordinal - 1),
})
.pipe(
Effect.mapError(
(cause) =>
new RunExecutionStartError({
commandId: input.commandId,
runId: input.run.id,
cause,
}),
),
);
yield* input.session
.startTurn({
appThread: input.appThread,
@@ -99,7 +99,7 @@ function commandThreadIds(command: OrchestrationV2Command): ReadonlyArray<Thread
case "thread.runtime-mode.set":
case "thread.interaction-mode.set":
case "thread.model-selection.set":
case "provider-session.release":
case "provider-session.detach":
case "message.dispatch":
case "run.interrupt":
case "queued-message.promote-to-steer":
@@ -620,6 +620,7 @@ export function materializeFixtureInput(input: {
steps.push({ type: "await", key: `run:${step.targetRunIndex}` });
}
steps.push({ type: "advance_clock", duration: "1 millis" });
steps.push({ type: "await_thread_idle", threadId: ids.threadId });
break;
case "rollback":
{
@@ -10,13 +10,10 @@
{"type":"emit_inbound","label":"item/completed/source-user","frame":{"method":"item/completed","params":{"item":{"type":"userMessage","id":"native-source-user-item","content":[{"type":"text","text":"Respond with the following text: source fork seed ok","text_elements":[]}]},"threadId":"native-source-thread","turnId":"native-source-turn"}}}
{"type":"emit_inbound","label":"item/completed/source-agent","frame":{"method":"item/completed","params":{"item":{"type":"agentMessage","id":"native-source-agent-item","text":"source fork seed ok","phase":"final_answer","memoryCitation":null},"threadId":"native-source-thread","turnId":"native-source-turn"}}}
{"type":"emit_inbound","label":"turn/completed/source","frame":{"method":"turn/completed","params":{"threadId":"native-source-thread","turn":{"id":"native-source-turn","items":[],"status":"completed","error":null,"startedAt":1776739349,"completedAt":1776739356,"durationMs":6434}}}}
{"type":"expect_outbound","label":"initialize/fork","frame":{"id":4,"method":"initialize","params":{"capabilities":{"experimentalApi":true},"clientInfo":{"name":"t3code_desktop","title":"T3 Code Desktop","version":"0.1.0"}}}}
{"type":"emit_inbound","label":"initialize/fork","frame":{"id":4,"result":{"userAgent":"t3code_desktop/0.120.0","codexHome":"/tmp/codex","platformFamily":"unix","platformOs":"macos"}}}
{"type":"expect_outbound","label":"initialized/fork","frame":{"method":"initialized"}}
{"type":"expect_outbound","label":"thread/fork","frame":{"id":5,"method":"thread/fork","params":{"threadId":"native-source-thread"}}}
{"type":"emit_inbound","label":"thread/fork","frame":{"id":5,"result":{"thread":{"id":"native-fork-thread","forkedFromId":"native-source-thread","preview":"","ephemeral":false,"modelProvider":"openai","createdAt":1776739360,"updatedAt":1776739360,"status":{"type":"idle"},"path":"/tmp/fork.jsonl","cwd":"/tmp/project","cliVersion":"0.120.0","source":"vscode","agentNickname":null,"agentRole":null,"gitInfo":null,"name":null,"turns":[]},"model":"gpt-5.4","modelProvider":"openai","serviceTier":"fast","cwd":"/tmp/project","approvalPolicy":"on-request","approvalsReviewer":"user","sandbox":{"type":"workspaceWrite","writableRoots":[],"readOnlyAccess":{"type":"fullAccess"},"networkAccess":false,"excludeTmpdirEnvVar":false,"excludeSlashTmp":false},"reasoningEffort":"xhigh"}}}
{"type":"expect_outbound","label":"turn/start/fork","frame":{"id":6,"method":"turn/start","params":{"input":[{"text":"Respond with the following text: fork native ok","type":"text"}],"threadId":"native-fork-thread"}}}
{"type":"emit_inbound","label":"turn/start/fork","frame":{"id":6,"result":{"turn":{"id":"native-fork-turn","items":[],"status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"expect_outbound","label":"thread/fork","frame":{"id":4,"method":"thread/fork","params":{"threadId":"native-source-thread"}}}
{"type":"emit_inbound","label":"thread/fork","frame":{"id":4,"result":{"thread":{"id":"native-fork-thread","forkedFromId":"native-source-thread","preview":"","ephemeral":false,"modelProvider":"openai","createdAt":1776739360,"updatedAt":1776739360,"status":{"type":"idle"},"path":"/tmp/fork.jsonl","cwd":"/tmp/project","cliVersion":"0.120.0","source":"vscode","agentNickname":null,"agentRole":null,"gitInfo":null,"name":null,"turns":[]},"model":"gpt-5.4","modelProvider":"openai","serviceTier":"fast","cwd":"/tmp/project","approvalPolicy":"on-request","approvalsReviewer":"user","sandbox":{"type":"workspaceWrite","writableRoots":[],"readOnlyAccess":{"type":"fullAccess"},"networkAccess":false,"excludeTmpdirEnvVar":false,"excludeSlashTmp":false},"reasoningEffort":"xhigh"}}}
{"type":"expect_outbound","label":"turn/start/fork","frame":{"id":5,"method":"turn/start","params":{"input":[{"text":"Respond with the following text: fork native ok","type":"text"}],"threadId":"native-fork-thread"}}}
{"type":"emit_inbound","label":"turn/start/fork","frame":{"id":5,"result":{"turn":{"id":"native-fork-turn","items":[],"status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"turn/started/fork","frame":{"method":"turn/started","params":{"threadId":"native-fork-thread","turn":{"id":"native-fork-turn","items":[],"status":"inProgress","error":null,"startedAt":1776739361,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"item/completed/fork-user","frame":{"method":"item/completed","params":{"item":{"type":"userMessage","id":"native-fork-user-item","content":[{"type":"text","text":"Respond with the following text: fork native ok","text_elements":[]}]},"threadId":"native-fork-thread","turnId":"native-fork-turn"}}}
{"type":"emit_inbound","label":"item/completed/fork-agent","frame":{"method":"item/completed","params":{"item":{"type":"agentMessage","id":"native-fork-agent-item","text":"fork native ok","phase":"final_answer","memoryCitation":null},"threadId":"native-fork-thread","turnId":"native-fork-turn"}}}
@@ -48,24 +48,21 @@
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":61,"windowDurationMins":300,"resetsAt":1777429830},"secondary":{"usedPercent":23,"windowDurationMins":10080,"resetsAt":1777959590},"credits":null,"planType":"pro","rateLimitReachedType":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019dd6ba-2681-7bf0-b051-141b0cbcbb27","status":{"type":"idle"}}}}
{"type":"emit_inbound","label":"turn/completed","frame":{"method":"turn/completed","params":{"threadId":"019dd6ba-2681-7bf0-b051-141b0cbcbb27","turn":{"id":"019dd6ba-416d-7902-95cf-d4179c3f4738","items":[],"status":"completed","error":null,"startedAt":1777424023,"completedAt":1777424025,"durationMs":1596}}}}
{"type":"expect_outbound","label":"initialize/fork","frame":{"id":5,"method":"initialize","params":{"capabilities":{"experimentalApi":true},"clientInfo":{"name":"t3code_desktop","title":"T3 Code Desktop","version":"0.1.0"}}}}
{"type":"emit_inbound","label":"initialize/fork","frame":{"id":5,"result":{"userAgent":"t3code_desktop/0.124.0-alpha.3","codexHome":"/Users/julius/.codex","platformFamily":"unix","platformOs":"macos"}}}
{"type":"expect_outbound","label":"initialized/fork","frame":{"method":"initialized"}}
{"type":"expect_outbound","label":"thread/fork","frame":{"id":6,"method":"thread/fork","params":{"threadId":"019dd6ba-2681-7bf0-b051-141b0cbcbb27"}}}
{"type":"expect_outbound","label":"thread/fork","frame":{"id":5,"method":"thread/fork","params":{"threadId":"019dd6ba-2681-7bf0-b051-141b0cbcbb27"}}}
{"type":"emit_inbound","label":"deprecationNotice","frame":{"method":"deprecationNotice","params":{"summary":"`[features].collab` is deprecated. Use `[features].multi_agent` instead.","details":"Enable it with `--enable multi_agent` or `[features].multi_agent` in config.toml. See https://developers.openai.com/codex/config-basic#feature-flags for details."}}}
{"type":"emit_inbound","label":"warning","frame":{"method":"warning","params":{"threadId":"019dd6ba-47b7-7092-8688-9cf7fe5f6498","message":"Under-development features enabled: apply_patch_freeform. Under-development features are incomplete and may behave unpredictably. To suppress this warning, set `suppress_unstable_features_warning = true` in /Users/julius/.codex/config.toml."}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"uidotsh","status":"starting","error":null}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"computer-use","status":"starting","error":null}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"codex_apps","status":"starting","error":null}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"computer-use","status":"ready","error":null}}}
{"type":"emit_inbound","label":"thread/fork","frame":{"id":6,"result":{"thread":{"id":"019dd6ba-47b7-7092-8688-9cf7fe5f6498","forkedFromId":"019dd6ba-2681-7bf0-b051-141b0cbcbb27","preview":"For this fork-boundary fixture, respond with exactly: fork boundary alpha","ephemeral":false,"modelProvider":"openai","createdAt":1777424025,"updatedAt":1777424025,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/04/28/rollout-2026-04-28T17-53-45-019dd6ba-47b7-7092-8688-9cf7fe5f6498.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1","cliVersion":"0.124.0-alpha.3","source":"vscode","agentNickname":null,"agentRole":null,"gitInfo":{"sha":"969e8ea4fac1f2066ed50dd4f82b5fd0014d8a4d","branch":"t3code/codex-turn-mapping","originUrl":"[email protected]:pingdotgg/t3code.git"},"name":null,"turns":[{"id":"019dd6ba-268b-7f82-8f4c-9fde0edcfd55","items":[{"type":"userMessage","id":"item-1","content":[{"type":"text","text":"For this fork-boundary fixture, respond with exactly: fork boundary alpha","text_elements":[]}]},{"type":"agentMessage","id":"item-2","text":"fork boundary alpha","phase":"final_answer","memoryCitation":null}],"status":"completed","error":null,"startedAt":1777424017,"completedAt":1777424023,"durationMs":6880},{"id":"019dd6ba-416d-7902-95cf-d4179c3f4738","items":[{"type":"userMessage","id":"item-3","content":[{"type":"text","text":"For this fork-boundary fixture, respond with exactly: fork boundary beta","text_elements":[]}]},{"type":"agentMessage","id":"item-4","text":"fork boundary beta","phase":"final_answer","memoryCitation":null}],"status":"completed","error":null,"startedAt":1777424023,"completedAt":1777424025,"durationMs":1596}]},"model":"gpt-5.5","modelProvider":"openai","serviceTier":"fast","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1","instructionSources":["/Users/julius/.codex/AGENTS.md","/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/AGENTS.md"],"approvalPolicy":"on-request","approvalsReviewer":"user","sandbox":{"type":"workspaceWrite","writableRoots":["/Users/julius/.codex/memories"],"readOnlyAccess":{"type":"fullAccess"},"networkAccess":false,"excludeTmpdirEnvVar":false,"excludeSlashTmp":false},"permissionProfile":{"network":{"enabled":false},"fileSystem":{"entries":[{"path":{"type":"special","value":{"kind":"root"}},"access":"read"},{"path":{"type":"special","value":{"kind":"current_working_directory"}},"access":"write"},{"path":{"type":"special","value":{"kind":"slash_tmp"}},"access":"write"},{"path":{"type":"special","value":{"kind":"tmpdir"}},"access":"write"},{"path":{"type":"path","path":"/Users/julius/.codex/memories"},"access":"write"},{"path":{"type":"path","path":"/Users/julius/Development/Work/codething-mvp/.git/worktrees/t3code-c1e5e1d1"},"access":"read"},{"path":{"type":"path","path":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/.git"},"access":"read"},{"path":{"type":"path","path":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/.codex"},"access":"read"}]}},"reasoningEffort":"medium"}}}
{"type":"expect_outbound","label":"thread/rollback","frame":{"id":7,"method":"thread/rollback","params":{"threadId":"019dd6ba-47b7-7092-8688-9cf7fe5f6498","numTurns":1}}}
{"type":"emit_inbound","label":"thread/fork","frame":{"id":5,"result":{"thread":{"id":"019dd6ba-47b7-7092-8688-9cf7fe5f6498","forkedFromId":"019dd6ba-2681-7bf0-b051-141b0cbcbb27","preview":"For this fork-boundary fixture, respond with exactly: fork boundary alpha","ephemeral":false,"modelProvider":"openai","createdAt":1777424025,"updatedAt":1777424025,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/04/28/rollout-2026-04-28T17-53-45-019dd6ba-47b7-7092-8688-9cf7fe5f6498.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1","cliVersion":"0.124.0-alpha.3","source":"vscode","agentNickname":null,"agentRole":null,"gitInfo":{"sha":"969e8ea4fac1f2066ed50dd4f82b5fd0014d8a4d","branch":"t3code/codex-turn-mapping","originUrl":"[email protected]:pingdotgg/t3code.git"},"name":null,"turns":[{"id":"019dd6ba-268b-7f82-8f4c-9fde0edcfd55","items":[{"type":"userMessage","id":"item-1","content":[{"type":"text","text":"For this fork-boundary fixture, respond with exactly: fork boundary alpha","text_elements":[]}]},{"type":"agentMessage","id":"item-2","text":"fork boundary alpha","phase":"final_answer","memoryCitation":null}],"status":"completed","error":null,"startedAt":1777424017,"completedAt":1777424023,"durationMs":6880},{"id":"019dd6ba-416d-7902-95cf-d4179c3f4738","items":[{"type":"userMessage","id":"item-3","content":[{"type":"text","text":"For this fork-boundary fixture, respond with exactly: fork boundary beta","text_elements":[]}]},{"type":"agentMessage","id":"item-4","text":"fork boundary beta","phase":"final_answer","memoryCitation":null}],"status":"completed","error":null,"startedAt":1777424023,"completedAt":1777424025,"durationMs":1596}]},"model":"gpt-5.5","modelProvider":"openai","serviceTier":"fast","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1","instructionSources":["/Users/julius/.codex/AGENTS.md","/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/AGENTS.md"],"approvalPolicy":"on-request","approvalsReviewer":"user","sandbox":{"type":"workspaceWrite","writableRoots":["/Users/julius/.codex/memories"],"readOnlyAccess":{"type":"fullAccess"},"networkAccess":false,"excludeTmpdirEnvVar":false,"excludeSlashTmp":false},"permissionProfile":{"network":{"enabled":false},"fileSystem":{"entries":[{"path":{"type":"special","value":{"kind":"root"}},"access":"read"},{"path":{"type":"special","value":{"kind":"current_working_directory"}},"access":"write"},{"path":{"type":"special","value":{"kind":"slash_tmp"}},"access":"write"},{"path":{"type":"special","value":{"kind":"tmpdir"}},"access":"write"},{"path":{"type":"path","path":"/Users/julius/.codex/memories"},"access":"write"},{"path":{"type":"path","path":"/Users/julius/Development/Work/codething-mvp/.git/worktrees/t3code-c1e5e1d1"},"access":"read"},{"path":{"type":"path","path":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/.git"},"access":"read"},{"path":{"type":"path","path":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/.codex"},"access":"read"}]}},"reasoningEffort":"medium"}}}
{"type":"expect_outbound","label":"thread/rollback","frame":{"id":6,"method":"thread/rollback","params":{"threadId":"019dd6ba-47b7-7092-8688-9cf7fe5f6498","numTurns":1}}}
{"type":"emit_inbound","label":"thread/tokenUsage/updated","frame":{"method":"thread/tokenUsage/updated","params":{"threadId":"019dd6ba-47b7-7092-8688-9cf7fe5f6498","turnId":"019dd6ba-416d-7902-95cf-d4179c3f4738","tokenUsage":{"total":{"totalTokens":53852,"inputTokens":53827,"cachedInputTokens":29952,"outputTokens":25,"reasoningOutputTokens":9},"last":{"totalTokens":26934,"inputTokens":26927,"cachedInputTokens":26496,"outputTokens":7,"reasoningOutputTokens":0},"modelContextWindow":258400}}}}
{"type":"emit_inbound","label":"thread/started","frame":{"method":"thread/started","params":{"thread":{"id":"019dd6ba-47b7-7092-8688-9cf7fe5f6498","forkedFromId":"019dd6ba-2681-7bf0-b051-141b0cbcbb27","preview":"For this fork-boundary fixture, respond with exactly: fork boundary alpha","ephemeral":false,"modelProvider":"openai","createdAt":1777424025,"updatedAt":1777424025,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/04/28/rollout-2026-04-28T17-53-45-019dd6ba-47b7-7092-8688-9cf7fe5f6498.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1","cliVersion":"0.124.0-alpha.3","source":"vscode","agentNickname":null,"agentRole":null,"gitInfo":{"sha":"969e8ea4fac1f2066ed50dd4f82b5fd0014d8a4d","branch":"t3code/codex-turn-mapping","originUrl":"[email protected]:pingdotgg/t3code.git"},"name":null,"turns":[{"id":"019dd6ba-268b-7f82-8f4c-9fde0edcfd55","items":[{"type":"userMessage","id":"item-1","content":[{"type":"text","text":"For this fork-boundary fixture, respond with exactly: fork boundary alpha","text_elements":[]}]},{"type":"agentMessage","id":"item-2","text":"fork boundary alpha","phase":"final_answer","memoryCitation":null}],"status":"completed","error":null,"startedAt":1777424017,"completedAt":1777424023,"durationMs":6880},{"id":"019dd6ba-416d-7902-95cf-d4179c3f4738","items":[{"type":"userMessage","id":"item-3","content":[{"type":"text","text":"For this fork-boundary fixture, respond with exactly: fork boundary beta","text_elements":[]}]},{"type":"agentMessage","id":"item-4","text":"fork boundary beta","phase":"final_answer","memoryCitation":null}],"status":"completed","error":null,"startedAt":1777424023,"completedAt":1777424025,"durationMs":1596}]}}}}
{"type":"emit_inbound","label":"thread/tokenUsage/updated","frame":{"method":"thread/tokenUsage/updated","params":{"threadId":"019dd6ba-47b7-7092-8688-9cf7fe5f6498","turnId":"019dd6ba-47e9-7ed2-ba44-374e8b74cf27","tokenUsage":{"total":{"totalTokens":53852,"inputTokens":53827,"cachedInputTokens":29952,"outputTokens":25,"reasoningOutputTokens":9},"last":{"totalTokens":10877,"inputTokens":0,"cachedInputTokens":0,"outputTokens":0,"reasoningOutputTokens":0},"modelContextWindow":258400}}}}
{"type":"emit_inbound","label":"thread/rollback","frame":{"id":7,"result":{"thread":{"id":"019dd6ba-47b7-7092-8688-9cf7fe5f6498","forkedFromId":null,"preview":"For this fork-boundary fixture, respond with exactly: fork boundary alpha","ephemeral":false,"modelProvider":"openai","createdAt":1777424025,"updatedAt":1777424025,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/04/28/rollout-2026-04-28T17-53-45-019dd6ba-47b7-7092-8688-9cf7fe5f6498.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1","cliVersion":"0.124.0-alpha.3","source":"vscode","agentNickname":null,"agentRole":null,"gitInfo":{"sha":"969e8ea4fac1f2066ed50dd4f82b5fd0014d8a4d","branch":"t3code/codex-turn-mapping","originUrl":"[email protected]:pingdotgg/t3code.git"},"name":null,"turns":[{"id":"019dd6ba-268b-7f82-8f4c-9fde0edcfd55","items":[{"type":"userMessage","id":"item-1","content":[{"type":"text","text":"For this fork-boundary fixture, respond with exactly: fork boundary alpha","text_elements":[]}]},{"type":"agentMessage","id":"item-2","text":"fork boundary alpha","phase":"final_answer","memoryCitation":null}],"status":"completed","error":null,"startedAt":1777424017,"completedAt":1777424023,"durationMs":6880}]}}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":8,"method":"turn/start","params":{"threadId":"019dd6ba-47b7-7092-8688-9cf7fe5f6498","input":[{"type":"text","text":"Repeat the user-visible conversation so far verbatim. Include only user and assistant messages. Do not include hidden system/developer content."}],"approvalPolicy":"never","sandboxPolicy":{"type":"readOnly","networkAccess":false}}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":8,"result":{"turn":{"id":"019dd6ba-47eb-7041-ad45-5abe752c28c9","items":[],"status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"thread/rollback","frame":{"id":6,"result":{"thread":{"id":"019dd6ba-47b7-7092-8688-9cf7fe5f6498","forkedFromId":null,"preview":"For this fork-boundary fixture, respond with exactly: fork boundary alpha","ephemeral":false,"modelProvider":"openai","createdAt":1777424025,"updatedAt":1777424025,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/04/28/rollout-2026-04-28T17-53-45-019dd6ba-47b7-7092-8688-9cf7fe5f6498.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1","cliVersion":"0.124.0-alpha.3","source":"vscode","agentNickname":null,"agentRole":null,"gitInfo":{"sha":"969e8ea4fac1f2066ed50dd4f82b5fd0014d8a4d","branch":"t3code/codex-turn-mapping","originUrl":"[email protected]:pingdotgg/t3code.git"},"name":null,"turns":[{"id":"019dd6ba-268b-7f82-8f4c-9fde0edcfd55","items":[{"type":"userMessage","id":"item-1","content":[{"type":"text","text":"For this fork-boundary fixture, respond with exactly: fork boundary alpha","text_elements":[]}]},{"type":"agentMessage","id":"item-2","text":"fork boundary alpha","phase":"final_answer","memoryCitation":null}],"status":"completed","error":null,"startedAt":1777424017,"completedAt":1777424023,"durationMs":6880}]}}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":7,"method":"turn/start","params":{"threadId":"019dd6ba-47b7-7092-8688-9cf7fe5f6498","input":[{"type":"text","text":"Repeat the user-visible conversation so far verbatim. Include only user and assistant messages. Do not include hidden system/developer content."}],"approvalPolicy":"never","sandboxPolicy":{"type":"readOnly","networkAccess":false}}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":7,"result":{"turn":{"id":"019dd6ba-47eb-7041-ad45-5abe752c28c9","items":[],"status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019dd6ba-47b7-7092-8688-9cf7fe5f6498","status":{"type":"active","activeFlags":[]}}}}
{"type":"emit_inbound","label":"turn/started","frame":{"method":"turn/started","params":{"threadId":"019dd6ba-47b7-7092-8688-9cf7fe5f6498","turn":{"id":"019dd6ba-47eb-7041-ad45-5abe752c28c9","items":[],"status":"inProgress","error":null,"startedAt":1777424025,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"uidotsh","status":"ready","error":null}}}
@@ -34,10 +34,7 @@
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":0,"windowDurationMins":300,"resetsAt":1780968999},"secondary":{"usedPercent":3,"windowDurationMins":10080,"resetsAt":1781296757},"credits":null,"individualLimit":null,"planType":"pro","rateLimitReachedType":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1","status":{"type":"idle"}}}}
{"type":"emit_inbound","label":"turn/completed","frame":{"method":"turn/completed","params":{"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1","turn":{"id":"019ea9a7-adb0-77a2-85a6-3d3b6ff5ef67","items":[],"itemsView":"notLoaded","status":"completed","error":null,"startedAt":1780962799,"completedAt":1780962804,"durationMs":5102}}}}
{"type":"expect_outbound","label":"initialize/fork:1","frame":{"id":4,"method":"initialize","params":{"capabilities":{"experimentalApi":true},"clientInfo":{"name":"t3code_desktop","title":"T3 Code Desktop","version":"0.1.0"}}}}
{"type":"emit_inbound","label":"initialize/fork:1","frame":{"id":4,"result":{"userAgent":"t3code_desktop/0.137.0 (Mac OS 26.5.1; arm64) dumb (t3code_desktop; 0.1.0)","codexHome":"/Users/julius/.codex","platformFamily":"unix","platformOs":"macos"}}}
{"type":"expect_outbound","label":"initialized/fork:1","frame":{"method":"initialized"}}
{"type":"expect_outbound","label":"thread/fork","frame":{"id":5,"method":"thread/fork","params":{"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1"}}}
{"type":"expect_outbound","label":"thread/fork","frame":{"id":4,"method":"thread/fork","params":{"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1"}}}
{"type":"emit_inbound","label":"deprecationNotice","frame":{"method":"deprecationNotice","params":{"summary":"`[features].collab` is deprecated. Use `[features].multi_agent` instead.","details":"Enable it with `--enable multi_agent` or `[features].multi_agent` in config.toml. See https://developers.openai.com/codex/config-basic#feature-flags for details."}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"uidotsh","status":"starting","error":null}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"xcodebuildmcp","status":"starting","error":null}}}
@@ -46,11 +43,11 @@
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"computer-use","status":"starting","error":null}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"openaiDeveloperDocs","status":"starting","error":null}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"node_repl","status":"ready","error":null}}}
{"type":"emit_inbound","label":"thread/fork","frame":{"id":5,"result":{"thread":{"id":"019ea9a7-c1e4-72a0-b56b-a7b751aa97e6","sessionId":"019ea9a7-c1e4-72a0-b56b-a7b751aa97e6","forkedFromId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1","parentThreadId":null,"preview":"Remember the opaque marker merge-source-4H8Q for later in this conversation. Respond with exactly: merge source stored","ephemeral":false,"modelProvider":"openai","createdAt":1780962804,"updatedAt":1780962804,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/06/08/rollout-2026-06-08T16-53-24-019ea9a7-c1e4-72a0-b56b-a7b751aa97e6.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server","cliVersion":"0.137.0","source":"vscode","threadSource":null,"agentNickname":null,"agentRole":null,"gitInfo":{"sha":"5115887f33051a4e25d2b427622a54656eeb9ab0","branch":"t3code/17b43ed6","originUrl":"[email protected]:pingdotgg/t3code.git"},"name":null,"turns":[{"id":"019ea9a7-adb0-77a2-85a6-3d3b6ff5ef67","items":[{"type":"userMessage","id":"item-1","clientId":null,"content":[{"type":"text","text":"Remember the opaque marker merge-source-4H8Q for later in this conversation. Respond with exactly: merge source stored","text_elements":[]}]},{"type":"agentMessage","id":"item-2","text":"merge source stored","phase":"final_answer","memoryCitation":null}],"itemsView":"full","status":"completed","error":null,"startedAt":1780962799,"completedAt":1780962804,"durationMs":5102}]},"model":"kindle-alpha","modelProvider":"openai","serviceTier":null,"cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server","runtimeWorkspaceRoots":["/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server"],"instructionSources":["/Users/julius/.codex/AGENTS.md","/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/AGENTS.md"],"approvalPolicy":"on-request","approvalsReviewer":"user","sandbox":{"type":"workspaceWrite","writableRoots":[],"networkAccess":false,"excludeTmpdirEnvVar":false,"excludeSlashTmp":false},"activePermissionProfile":{"id":":workspace","extends":null},"reasoningEffort":"medium"}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":6,"method":"turn/start","params":{"input":[{"text":"Remember the fork-local marker merge-fork-7T2W. Respond with exactly: merge fork stored","type":"text"}],"threadId":"019ea9a7-c1e4-72a0-b56b-a7b751aa97e6"}}}
{"type":"emit_inbound","label":"thread/fork","frame":{"id":4,"result":{"thread":{"id":"019ea9a7-c1e4-72a0-b56b-a7b751aa97e6","sessionId":"019ea9a7-c1e4-72a0-b56b-a7b751aa97e6","forkedFromId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1","parentThreadId":null,"preview":"Remember the opaque marker merge-source-4H8Q for later in this conversation. Respond with exactly: merge source stored","ephemeral":false,"modelProvider":"openai","createdAt":1780962804,"updatedAt":1780962804,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/06/08/rollout-2026-06-08T16-53-24-019ea9a7-c1e4-72a0-b56b-a7b751aa97e6.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server","cliVersion":"0.137.0","source":"vscode","threadSource":null,"agentNickname":null,"agentRole":null,"gitInfo":{"sha":"5115887f33051a4e25d2b427622a54656eeb9ab0","branch":"t3code/17b43ed6","originUrl":"[email protected]:pingdotgg/t3code.git"},"name":null,"turns":[{"id":"019ea9a7-adb0-77a2-85a6-3d3b6ff5ef67","items":[{"type":"userMessage","id":"item-1","clientId":null,"content":[{"type":"text","text":"Remember the opaque marker merge-source-4H8Q for later in this conversation. Respond with exactly: merge source stored","text_elements":[]}]},{"type":"agentMessage","id":"item-2","text":"merge source stored","phase":"final_answer","memoryCitation":null}],"itemsView":"full","status":"completed","error":null,"startedAt":1780962799,"completedAt":1780962804,"durationMs":5102}]},"model":"kindle-alpha","modelProvider":"openai","serviceTier":null,"cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server","runtimeWorkspaceRoots":["/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server"],"instructionSources":["/Users/julius/.codex/AGENTS.md","/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/AGENTS.md"],"approvalPolicy":"on-request","approvalsReviewer":"user","sandbox":{"type":"workspaceWrite","writableRoots":[],"networkAccess":false,"excludeTmpdirEnvVar":false,"excludeSlashTmp":false},"activePermissionProfile":{"id":":workspace","extends":null},"reasoningEffort":"medium"}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":5,"method":"turn/start","params":{"input":[{"text":"Remember the fork-local marker merge-fork-7T2W. Respond with exactly: merge fork stored","type":"text"}],"threadId":"019ea9a7-c1e4-72a0-b56b-a7b751aa97e6"}}}
{"type":"emit_inbound","label":"thread/tokenUsage/updated","frame":{"method":"thread/tokenUsage/updated","params":{"threadId":"019ea9a7-c1e4-72a0-b56b-a7b751aa97e6","turnId":"019ea9a7-adb0-77a2-85a6-3d3b6ff5ef67","tokenUsage":{"total":{"totalTokens":18446,"inputTokens":18439,"cachedInputTokens":18304,"outputTokens":7,"reasoningOutputTokens":0},"last":{"totalTokens":18446,"inputTokens":18439,"cachedInputTokens":18304,"outputTokens":7,"reasoningOutputTokens":0},"modelContextWindow":258400}}}}
{"type":"emit_inbound","label":"thread/started","frame":{"method":"thread/started","params":{"thread":{"id":"019ea9a7-c1e4-72a0-b56b-a7b751aa97e6","sessionId":"019ea9a7-c1e4-72a0-b56b-a7b751aa97e6","forkedFromId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1","parentThreadId":null,"preview":"Remember the opaque marker merge-source-4H8Q for later in this conversation. Respond with exactly: merge source stored","ephemeral":false,"modelProvider":"openai","createdAt":1780962804,"updatedAt":1780962804,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/06/08/rollout-2026-06-08T16-53-24-019ea9a7-c1e4-72a0-b56b-a7b751aa97e6.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server","cliVersion":"0.137.0","source":"vscode","threadSource":null,"agentNickname":null,"agentRole":null,"gitInfo":{"sha":"5115887f33051a4e25d2b427622a54656eeb9ab0","branch":"t3code/17b43ed6","originUrl":"[email protected]:pingdotgg/t3code.git"},"name":null,"turns":[]}}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":6,"result":{"turn":{"id":"019ea9a7-c370-73a2-a906-f722f57cb683","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":5,"result":{"turn":{"id":"019ea9a7-c370-73a2-a906-f722f57cb683","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a7-c1e4-72a0-b56b-a7b751aa97e6","status":{"type":"active","activeFlags":[]}}}}
{"type":"emit_inbound","label":"turn/started","frame":{"method":"turn/started","params":{"threadId":"019ea9a7-c1e4-72a0-b56b-a7b751aa97e6","turn":{"id":"019ea9a7-c370-73a2-a906-f722f57cb683","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":1780962804,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"computer-use","status":"ready","error":null}}}
@@ -69,8 +66,8 @@
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":0,"windowDurationMins":300,"resetsAt":1780968999},"secondary":{"usedPercent":3,"windowDurationMins":10080,"resetsAt":1781296757},"credits":null,"individualLimit":null,"planType":"pro","rateLimitReachedType":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a7-c1e4-72a0-b56b-a7b751aa97e6","status":{"type":"idle"}}}}
{"type":"emit_inbound","label":"turn/completed","frame":{"method":"turn/completed","params":{"threadId":"019ea9a7-c1e4-72a0-b56b-a7b751aa97e6","turn":{"id":"019ea9a7-c370-73a2-a906-f722f57cb683","items":[],"itemsView":"notLoaded","status":"completed","error":null,"startedAt":1780962804,"completedAt":1780962809,"durationMs":4675}}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":7,"method":"turn/start","params":{"input":[{"text":"Context handoff (merge_back / fork_delta_summary):\nMerge-back context from forked conversation.\n\nFork delta:\n- User introduced opaque marker merge-fork-7T2W.\n- Assistant confirmed: merge fork stored\n\nUser message:\nRetain the transferred fork marker for later. Respond with exactly: merge delta stored","type":"text"}],"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1"}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":7,"result":{"turn":{"id":"019ea9a7-d5bd-7c13-a5ae-7479b421a677","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":6,"method":"turn/start","params":{"input":[{"text":"Context handoff (merge_back / fork_delta_summary):\nMerge-back context from forked conversation.\n\nFork delta:\n- User introduced opaque marker merge-fork-7T2W.\n- Assistant confirmed: merge fork stored\n\nUser message:\nRetain the transferred fork marker for later. Respond with exactly: merge delta stored","type":"text"}],"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1"}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":6,"result":{"turn":{"id":"019ea9a7-d5bd-7c13-a5ae-7479b421a677","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1","status":{"type":"active","activeFlags":[]}}}}
{"type":"emit_inbound","label":"turn/started","frame":{"method":"turn/started","params":{"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1","turn":{"id":"019ea9a7-d5bd-7c13-a5ae-7479b421a677","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":1780962809,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"userMessage","id":"a55b36a2-aca0-49e2-888c-03d7ea045d0d","clientId":null,"content":[{"type":"text","text":"Context handoff (merge_back / fork_delta_summary):\nMerge-back context from forked conversation.\n\nFork delta:\n- User introduced opaque marker merge-fork-7T2W.\n- Assistant confirmed: merge fork stored\n\nUser message:\nRetain the transferred fork marker for later. Respond with exactly: merge delta stored","text_elements":[]}]},"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1","turnId":"019ea9a7-d5bd-7c13-a5ae-7479b421a677","startedAtMs":1780962809285}}}
@@ -84,8 +81,8 @@
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":0,"windowDurationMins":300,"resetsAt":1780968999},"secondary":{"usedPercent":3,"windowDurationMins":10080,"resetsAt":1781296757},"credits":null,"individualLimit":null,"planType":"pro","rateLimitReachedType":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1","status":{"type":"idle"}}}}
{"type":"emit_inbound","label":"turn/completed","frame":{"method":"turn/completed","params":{"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1","turn":{"id":"019ea9a7-d5bd-7c13-a5ae-7479b421a677","items":[],"itemsView":"notLoaded","status":"completed","error":null,"startedAt":1780962809,"completedAt":1780962810,"durationMs":1414}}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":8,"method":"turn/start","params":{"input":[{"text":"Return the source marker followed by the transferred fork marker, separated by a single | character. Respond with only the markers and separator.","type":"text"}],"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1"}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":8,"result":{"turn":{"id":"019ea9a7-db48-7bd3-9c20-3d806cf8a702","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":7,"method":"turn/start","params":{"input":[{"text":"Return the source marker followed by the transferred fork marker, separated by a single | character. Respond with only the markers and separator.","type":"text"}],"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1"}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":7,"result":{"turn":{"id":"019ea9a7-db48-7bd3-9c20-3d806cf8a702","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1","status":{"type":"active","activeFlags":[]}}}}
{"type":"emit_inbound","label":"turn/started","frame":{"method":"turn/started","params":{"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1","turn":{"id":"019ea9a7-db48-7bd3-9c20-3d806cf8a702","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":1780962810,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"userMessage","id":"cbaa6105-6995-4c6a-811f-276491c56bd8","clientId":null,"content":[{"type":"text","text":"Return the source marker followed by the transferred fork marker, separated by a single | character. Respond with only the markers and separator.","text_elements":[]}]},"threadId":"019ea9a7-ac5e-74f0-a17c-75426d4c40c1","turnId":"019ea9a7-db48-7bd3-9c20-3d806cf8a702","startedAtMs":1780962810702}}}
@@ -35,10 +35,7 @@
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":0,"windowDurationMins":300,"resetsAt":1780968999},"secondary":{"usedPercent":3,"windowDurationMins":10080,"resetsAt":1781296757},"credits":null,"individualLimit":null,"planType":"pro","rateLimitReachedType":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","status":{"type":"idle"}}}}
{"type":"emit_inbound","label":"turn/completed","frame":{"method":"turn/completed","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","turn":{"id":"019ea9a7-e43a-74f2-b94e-99f168de38fd","items":[],"itemsView":"notLoaded","status":"completed","error":null,"startedAt":1780962813,"completedAt":1780962817,"durationMs":4111}}}}
{"type":"expect_outbound","label":"initialize/fork:1","frame":{"id":4,"method":"initialize","params":{"capabilities":{"experimentalApi":true},"clientInfo":{"name":"t3code_desktop","title":"T3 Code Desktop","version":"0.1.0"}}}}
{"type":"emit_inbound","label":"initialize/fork:1","frame":{"id":4,"result":{"userAgent":"t3code_desktop/0.137.0 (Mac OS 26.5.1; arm64) dumb (t3code_desktop; 0.1.0)","codexHome":"/Users/julius/.codex","platformFamily":"unix","platformOs":"macos"}}}
{"type":"expect_outbound","label":"initialized/fork:1","frame":{"method":"initialized"}}
{"type":"expect_outbound","label":"thread/fork","frame":{"id":5,"method":"thread/fork","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce"}}}
{"type":"expect_outbound","label":"thread/fork","frame":{"id":4,"method":"thread/fork","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce"}}}
{"type":"emit_inbound","label":"deprecationNotice","frame":{"method":"deprecationNotice","params":{"summary":"`[features].collab` is deprecated. Use `[features].multi_agent` instead.","details":"Enable it with `--enable multi_agent` or `[features].multi_agent` in config.toml. See https://developers.openai.com/codex/config-basic#feature-flags for details."}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"computer-use","status":"starting","error":null}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"codex_apps","status":"starting","error":null}}}
@@ -47,11 +44,11 @@
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"xcodebuildmcp","status":"starting","error":null}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"node_repl","status":"starting","error":null}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"node_repl","status":"ready","error":null}}}
{"type":"emit_inbound","label":"thread/fork","frame":{"id":5,"result":{"thread":{"id":"019ea9a7-f48f-74e2-b87e-4a7e9313b57a","sessionId":"019ea9a7-f48f-74e2-b87e-4a7e9313b57a","forkedFromId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","parentThreadId":null,"preview":"Remember the opaque marker merge-sibling-source-3C7K for later in this conversation. Respond with exactly: merge sibling source stored","ephemeral":false,"modelProvider":"openai","createdAt":1780962817,"updatedAt":1780962817,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/06/08/rollout-2026-06-08T16-53-37-019ea9a7-f48f-74e2-b87e-4a7e9313b57a.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server","cliVersion":"0.137.0","source":"vscode","threadSource":null,"agentNickname":null,"agentRole":null,"gitInfo":{"sha":"5115887f33051a4e25d2b427622a54656eeb9ab0","branch":"t3code/17b43ed6","originUrl":"[email protected]:pingdotgg/t3code.git"},"name":null,"turns":[{"id":"019ea9a7-e43a-74f2-b94e-99f168de38fd","items":[{"type":"userMessage","id":"item-1","clientId":null,"content":[{"type":"text","text":"Remember the opaque marker merge-sibling-source-3C7K for later in this conversation. Respond with exactly: merge sibling source stored","text_elements":[]}]},{"type":"agentMessage","id":"item-2","text":"merge sibling source stored","phase":"final_answer","memoryCitation":null}],"itemsView":"full","status":"completed","error":null,"startedAt":1780962813,"completedAt":1780962817,"durationMs":4111}]},"model":"kindle-alpha","modelProvider":"openai","serviceTier":null,"cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server","runtimeWorkspaceRoots":["/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server"],"instructionSources":["/Users/julius/.codex/AGENTS.md","/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/AGENTS.md"],"approvalPolicy":"on-request","approvalsReviewer":"user","sandbox":{"type":"workspaceWrite","writableRoots":[],"networkAccess":false,"excludeTmpdirEnvVar":false,"excludeSlashTmp":false},"activePermissionProfile":{"id":":workspace","extends":null},"reasoningEffort":"medium"}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":6,"method":"turn/start","params":{"input":[{"text":"Remember the fork-local marker merge-sibling-first-6V2J. Respond with exactly: first merge sibling stored","type":"text"}],"threadId":"019ea9a7-f48f-74e2-b87e-4a7e9313b57a"}}}
{"type":"emit_inbound","label":"thread/fork","frame":{"id":4,"result":{"thread":{"id":"019ea9a7-f48f-74e2-b87e-4a7e9313b57a","sessionId":"019ea9a7-f48f-74e2-b87e-4a7e9313b57a","forkedFromId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","parentThreadId":null,"preview":"Remember the opaque marker merge-sibling-source-3C7K for later in this conversation. Respond with exactly: merge sibling source stored","ephemeral":false,"modelProvider":"openai","createdAt":1780962817,"updatedAt":1780962817,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/06/08/rollout-2026-06-08T16-53-37-019ea9a7-f48f-74e2-b87e-4a7e9313b57a.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server","cliVersion":"0.137.0","source":"vscode","threadSource":null,"agentNickname":null,"agentRole":null,"gitInfo":{"sha":"5115887f33051a4e25d2b427622a54656eeb9ab0","branch":"t3code/17b43ed6","originUrl":"[email protected]:pingdotgg/t3code.git"},"name":null,"turns":[{"id":"019ea9a7-e43a-74f2-b94e-99f168de38fd","items":[{"type":"userMessage","id":"item-1","clientId":null,"content":[{"type":"text","text":"Remember the opaque marker merge-sibling-source-3C7K for later in this conversation. Respond with exactly: merge sibling source stored","text_elements":[]}]},{"type":"agentMessage","id":"item-2","text":"merge sibling source stored","phase":"final_answer","memoryCitation":null}],"itemsView":"full","status":"completed","error":null,"startedAt":1780962813,"completedAt":1780962817,"durationMs":4111}]},"model":"kindle-alpha","modelProvider":"openai","serviceTier":null,"cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server","runtimeWorkspaceRoots":["/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server"],"instructionSources":["/Users/julius/.codex/AGENTS.md","/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/AGENTS.md"],"approvalPolicy":"on-request","approvalsReviewer":"user","sandbox":{"type":"workspaceWrite","writableRoots":[],"networkAccess":false,"excludeTmpdirEnvVar":false,"excludeSlashTmp":false},"activePermissionProfile":{"id":":workspace","extends":null},"reasoningEffort":"medium"}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":5,"method":"turn/start","params":{"input":[{"text":"Remember the fork-local marker merge-sibling-first-6V2J. Respond with exactly: first merge sibling stored","type":"text"}],"threadId":"019ea9a7-f48f-74e2-b87e-4a7e9313b57a"}}}
{"type":"emit_inbound","label":"thread/tokenUsage/updated","frame":{"method":"thread/tokenUsage/updated","params":{"threadId":"019ea9a7-f48f-74e2-b87e-4a7e9313b57a","turnId":"019ea9a7-e43a-74f2-b94e-99f168de38fd","tokenUsage":{"total":{"totalTokens":18450,"inputTokens":18442,"cachedInputTokens":18304,"outputTokens":8,"reasoningOutputTokens":0},"last":{"totalTokens":18450,"inputTokens":18442,"cachedInputTokens":18304,"outputTokens":8,"reasoningOutputTokens":0},"modelContextWindow":258400}}}}
{"type":"emit_inbound","label":"thread/started","frame":{"method":"thread/started","params":{"thread":{"id":"019ea9a7-f48f-74e2-b87e-4a7e9313b57a","sessionId":"019ea9a7-f48f-74e2-b87e-4a7e9313b57a","forkedFromId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","parentThreadId":null,"preview":"Remember the opaque marker merge-sibling-source-3C7K for later in this conversation. Respond with exactly: merge sibling source stored","ephemeral":false,"modelProvider":"openai","createdAt":1780962817,"updatedAt":1780962817,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/06/08/rollout-2026-06-08T16-53-37-019ea9a7-f48f-74e2-b87e-4a7e9313b57a.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server","cliVersion":"0.137.0","source":"vscode","threadSource":null,"agentNickname":null,"agentRole":null,"gitInfo":{"sha":"5115887f33051a4e25d2b427622a54656eeb9ab0","branch":"t3code/17b43ed6","originUrl":"[email protected]:pingdotgg/t3code.git"},"name":null,"turns":[]}}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":6,"result":{"turn":{"id":"019ea9a7-f5bd-7c22-a906-5625e1d8564d","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":5,"result":{"turn":{"id":"019ea9a7-f5bd-7c22-a906-5625e1d8564d","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a7-f48f-74e2-b87e-4a7e9313b57a","status":{"type":"active","activeFlags":[]}}}}
{"type":"emit_inbound","label":"turn/started","frame":{"method":"turn/started","params":{"threadId":"019ea9a7-f48f-74e2-b87e-4a7e9313b57a","turn":{"id":"019ea9a7-f5bd-7c22-a906-5625e1d8564d","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":1780962817,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"computer-use","status":"ready","error":null}}}
@@ -71,10 +68,7 @@
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":0,"windowDurationMins":300,"resetsAt":1780968999},"secondary":{"usedPercent":3,"windowDurationMins":10080,"resetsAt":1781296757},"credits":null,"individualLimit":null,"planType":"pro","rateLimitReachedType":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a7-f48f-74e2-b87e-4a7e9313b57a","status":{"type":"idle"}}}}
{"type":"emit_inbound","label":"turn/completed","frame":{"method":"turn/completed","params":{"threadId":"019ea9a7-f48f-74e2-b87e-4a7e9313b57a","turn":{"id":"019ea9a7-f5bd-7c22-a906-5625e1d8564d","items":[],"itemsView":"notLoaded","status":"completed","error":null,"startedAt":1780962817,"completedAt":1780962822,"durationMs":4566}}}}
{"type":"expect_outbound","label":"initialize/fork:2","frame":{"id":7,"method":"initialize","params":{"capabilities":{"experimentalApi":true},"clientInfo":{"name":"t3code_desktop","title":"T3 Code Desktop","version":"0.1.0"}}}}
{"type":"emit_inbound","label":"initialize/fork:2","frame":{"id":7,"result":{"userAgent":"t3code_desktop/0.137.0 (Mac OS 26.5.1; arm64) dumb (t3code_desktop; 0.1.0)","codexHome":"/Users/julius/.codex","platformFamily":"unix","platformOs":"macos"}}}
{"type":"expect_outbound","label":"initialized/fork:2","frame":{"method":"initialized"}}
{"type":"expect_outbound","label":"thread/fork","frame":{"id":8,"method":"thread/fork","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce"}}}
{"type":"expect_outbound","label":"thread/fork","frame":{"id":6,"method":"thread/fork","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce"}}}
{"type":"emit_inbound","label":"deprecationNotice","frame":{"method":"deprecationNotice","params":{"summary":"`[features].collab` is deprecated. Use `[features].multi_agent` instead.","details":"Enable it with `--enable multi_agent` or `[features].multi_agent` in config.toml. See https://developers.openai.com/codex/config-basic#feature-flags for details."}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"node_repl","status":"starting","error":null}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"uidotsh","status":"starting","error":null}}}
@@ -83,11 +77,11 @@
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"openaiDeveloperDocs","status":"starting","error":null}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"computer-use","status":"starting","error":null}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"node_repl","status":"ready","error":null}}}
{"type":"emit_inbound","label":"thread/fork","frame":{"id":8,"result":{"thread":{"id":"019ea9a8-079f-7100-bbdf-74026e9c20c1","sessionId":"019ea9a8-079f-7100-bbdf-74026e9c20c1","forkedFromId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","parentThreadId":null,"preview":"Remember the opaque marker merge-sibling-source-3C7K for later in this conversation. Respond with exactly: merge sibling source stored","ephemeral":false,"modelProvider":"openai","createdAt":1780962822,"updatedAt":1780962822,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/06/08/rollout-2026-06-08T16-53-42-019ea9a8-079f-7100-bbdf-74026e9c20c1.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server","cliVersion":"0.137.0","source":"vscode","threadSource":null,"agentNickname":null,"agentRole":null,"gitInfo":{"sha":"5115887f33051a4e25d2b427622a54656eeb9ab0","branch":"t3code/17b43ed6","originUrl":"[email protected]:pingdotgg/t3code.git"},"name":null,"turns":[{"id":"019ea9a7-e43a-74f2-b94e-99f168de38fd","items":[{"type":"userMessage","id":"item-1","clientId":null,"content":[{"type":"text","text":"Remember the opaque marker merge-sibling-source-3C7K for later in this conversation. Respond with exactly: merge sibling source stored","text_elements":[]}]},{"type":"agentMessage","id":"item-2","text":"merge sibling source stored","phase":"final_answer","memoryCitation":null}],"itemsView":"full","status":"completed","error":null,"startedAt":1780962813,"completedAt":1780962817,"durationMs":4111}]},"model":"kindle-alpha","modelProvider":"openai","serviceTier":null,"cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server","runtimeWorkspaceRoots":["/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server"],"instructionSources":["/Users/julius/.codex/AGENTS.md","/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/AGENTS.md"],"approvalPolicy":"on-request","approvalsReviewer":"user","sandbox":{"type":"workspaceWrite","writableRoots":[],"networkAccess":false,"excludeTmpdirEnvVar":false,"excludeSlashTmp":false},"activePermissionProfile":{"id":":workspace","extends":null},"reasoningEffort":"medium"}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":9,"method":"turn/start","params":{"input":[{"text":"Remember the fork-local marker merge-sibling-second-9X5B. Respond with exactly: second merge sibling stored","type":"text"}],"threadId":"019ea9a8-079f-7100-bbdf-74026e9c20c1"}}}
{"type":"emit_inbound","label":"thread/fork","frame":{"id":6,"result":{"thread":{"id":"019ea9a8-079f-7100-bbdf-74026e9c20c1","sessionId":"019ea9a8-079f-7100-bbdf-74026e9c20c1","forkedFromId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","parentThreadId":null,"preview":"Remember the opaque marker merge-sibling-source-3C7K for later in this conversation. Respond with exactly: merge sibling source stored","ephemeral":false,"modelProvider":"openai","createdAt":1780962822,"updatedAt":1780962822,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/06/08/rollout-2026-06-08T16-53-42-019ea9a8-079f-7100-bbdf-74026e9c20c1.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server","cliVersion":"0.137.0","source":"vscode","threadSource":null,"agentNickname":null,"agentRole":null,"gitInfo":{"sha":"5115887f33051a4e25d2b427622a54656eeb9ab0","branch":"t3code/17b43ed6","originUrl":"[email protected]:pingdotgg/t3code.git"},"name":null,"turns":[{"id":"019ea9a7-e43a-74f2-b94e-99f168de38fd","items":[{"type":"userMessage","id":"item-1","clientId":null,"content":[{"type":"text","text":"Remember the opaque marker merge-sibling-source-3C7K for later in this conversation. Respond with exactly: merge sibling source stored","text_elements":[]}]},{"type":"agentMessage","id":"item-2","text":"merge sibling source stored","phase":"final_answer","memoryCitation":null}],"itemsView":"full","status":"completed","error":null,"startedAt":1780962813,"completedAt":1780962817,"durationMs":4111}]},"model":"kindle-alpha","modelProvider":"openai","serviceTier":null,"cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server","runtimeWorkspaceRoots":["/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server"],"instructionSources":["/Users/julius/.codex/AGENTS.md","/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/AGENTS.md"],"approvalPolicy":"on-request","approvalsReviewer":"user","sandbox":{"type":"workspaceWrite","writableRoots":[],"networkAccess":false,"excludeTmpdirEnvVar":false,"excludeSlashTmp":false},"activePermissionProfile":{"id":":workspace","extends":null},"reasoningEffort":"medium"}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":7,"method":"turn/start","params":{"input":[{"text":"Remember the fork-local marker merge-sibling-second-9X5B. Respond with exactly: second merge sibling stored","type":"text"}],"threadId":"019ea9a8-079f-7100-bbdf-74026e9c20c1"}}}
{"type":"emit_inbound","label":"thread/tokenUsage/updated","frame":{"method":"thread/tokenUsage/updated","params":{"threadId":"019ea9a8-079f-7100-bbdf-74026e9c20c1","turnId":"019ea9a7-e43a-74f2-b94e-99f168de38fd","tokenUsage":{"total":{"totalTokens":18450,"inputTokens":18442,"cachedInputTokens":18304,"outputTokens":8,"reasoningOutputTokens":0},"last":{"totalTokens":18450,"inputTokens":18442,"cachedInputTokens":18304,"outputTokens":8,"reasoningOutputTokens":0},"modelContextWindow":258400}}}}
{"type":"emit_inbound","label":"thread/started","frame":{"method":"thread/started","params":{"thread":{"id":"019ea9a8-079f-7100-bbdf-74026e9c20c1","sessionId":"019ea9a8-079f-7100-bbdf-74026e9c20c1","forkedFromId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","parentThreadId":null,"preview":"Remember the opaque marker merge-sibling-source-3C7K for later in this conversation. Respond with exactly: merge sibling source stored","ephemeral":false,"modelProvider":"openai","createdAt":1780962822,"updatedAt":1780962822,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/06/08/rollout-2026-06-08T16-53-42-019ea9a8-079f-7100-bbdf-74026e9c20c1.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-17b43ed6/apps/server","cliVersion":"0.137.0","source":"vscode","threadSource":null,"agentNickname":null,"agentRole":null,"gitInfo":{"sha":"5115887f33051a4e25d2b427622a54656eeb9ab0","branch":"t3code/17b43ed6","originUrl":"[email protected]:pingdotgg/t3code.git"},"name":null,"turns":[]}}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":9,"result":{"turn":{"id":"019ea9a8-093e-7f11-8cd1-a38c032d4642","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":7,"result":{"turn":{"id":"019ea9a8-093e-7f11-8cd1-a38c032d4642","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a8-079f-7100-bbdf-74026e9c20c1","status":{"type":"active","activeFlags":[]}}}}
{"type":"emit_inbound","label":"turn/started","frame":{"method":"turn/started","params":{"threadId":"019ea9a8-079f-7100-bbdf-74026e9c20c1","turn":{"id":"019ea9a8-093e-7f11-8cd1-a38c032d4642","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":1780962822,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"computer-use","status":"ready","error":null}}}
@@ -107,8 +101,8 @@
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":0,"windowDurationMins":300,"resetsAt":1780968999},"secondary":{"usedPercent":3,"windowDurationMins":10080,"resetsAt":1781296757},"credits":null,"individualLimit":null,"planType":"pro","rateLimitReachedType":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a8-079f-7100-bbdf-74026e9c20c1","status":{"type":"idle"}}}}
{"type":"emit_inbound","label":"turn/completed","frame":{"method":"turn/completed","params":{"threadId":"019ea9a8-079f-7100-bbdf-74026e9c20c1","turn":{"id":"019ea9a8-093e-7f11-8cd1-a38c032d4642","items":[],"itemsView":"notLoaded","status":"completed","error":null,"startedAt":1780962822,"completedAt":1780962826,"durationMs":4114}}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":10,"method":"turn/start","params":{"input":[{"text":"Context handoff (merge_back / fork_delta_summary):\nMerge-back context from first forked conversation.\n\nFork delta:\n- User introduced opaque marker merge-sibling-first-6V2J.\n- Assistant confirmed: first merge sibling stored\n\nUser message:\nRetain the first transferred marker for later. Respond with exactly: first merge delta stored","type":"text"}],"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce"}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":10,"result":{"turn":{"id":"019ea9a8-1956-7183-acaa-f43d53da7a22","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":8,"method":"turn/start","params":{"input":[{"text":"Context handoff (merge_back / fork_delta_summary):\nMerge-back context from first forked conversation.\n\nFork delta:\n- User introduced opaque marker merge-sibling-first-6V2J.\n- Assistant confirmed: first merge sibling stored\n\nUser message:\nRetain the first transferred marker for later. Respond with exactly: first merge delta stored","type":"text"}],"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce"}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":8,"result":{"turn":{"id":"019ea9a8-1956-7183-acaa-f43d53da7a22","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","status":{"type":"active","activeFlags":[]}}}}
{"type":"emit_inbound","label":"turn/started","frame":{"method":"turn/started","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","turn":{"id":"019ea9a8-1956-7183-acaa-f43d53da7a22","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":1780962826,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"userMessage","id":"7eabb7de-b7f9-4c1d-b82d-cfbbe71c4ea4","clientId":null,"content":[{"type":"text","text":"Context handoff (merge_back / fork_delta_summary):\nMerge-back context from first forked conversation.\n\nFork delta:\n- User introduced opaque marker merge-sibling-first-6V2J.\n- Assistant confirmed: first merge sibling stored\n\nUser message:\nRetain the first transferred marker for later. Respond with exactly: first merge delta stored","text_elements":[]}]},"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","turnId":"019ea9a8-1956-7183-acaa-f43d53da7a22","startedAtMs":1780962826590}}}
@@ -123,8 +117,8 @@
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":0,"windowDurationMins":300,"resetsAt":1780968999},"secondary":{"usedPercent":3,"windowDurationMins":10080,"resetsAt":1781296757},"credits":null,"individualLimit":null,"planType":"pro","rateLimitReachedType":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","status":{"type":"idle"}}}}
{"type":"emit_inbound","label":"turn/completed","frame":{"method":"turn/completed","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","turn":{"id":"019ea9a8-1956-7183-acaa-f43d53da7a22","items":[],"itemsView":"notLoaded","status":"completed","error":null,"startedAt":1780962826,"completedAt":1780962828,"durationMs":1738}}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":11,"method":"turn/start","params":{"input":[{"text":"Context handoff (merge_back / fork_delta_summary):\nMerge-back context from second forked conversation.\n\nFork delta:\n- User introduced opaque marker merge-sibling-second-9X5B.\n- Assistant confirmed: second merge sibling stored\n\nUser message:\nRetain the second transferred marker for later. Respond with exactly: second merge delta stored","type":"text"}],"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce"}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":11,"result":{"turn":{"id":"019ea9a8-2025-7de2-bb4b-ecd86a568956","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":9,"method":"turn/start","params":{"input":[{"text":"Context handoff (merge_back / fork_delta_summary):\nMerge-back context from second forked conversation.\n\nFork delta:\n- User introduced opaque marker merge-sibling-second-9X5B.\n- Assistant confirmed: second merge sibling stored\n\nUser message:\nRetain the second transferred marker for later. Respond with exactly: second merge delta stored","type":"text"}],"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce"}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":9,"result":{"turn":{"id":"019ea9a8-2025-7de2-bb4b-ecd86a568956","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","status":{"type":"active","activeFlags":[]}}}}
{"type":"emit_inbound","label":"turn/started","frame":{"method":"turn/started","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","turn":{"id":"019ea9a8-2025-7de2-bb4b-ecd86a568956","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":1780962828,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"userMessage","id":"fa82b56f-507e-488a-b784-899434c3d8cc","clientId":null,"content":[{"type":"text","text":"Context handoff (merge_back / fork_delta_summary):\nMerge-back context from second forked conversation.\n\nFork delta:\n- User introduced opaque marker merge-sibling-second-9X5B.\n- Assistant confirmed: second merge sibling stored\n\nUser message:\nRetain the second transferred marker for later. Respond with exactly: second merge delta stored","text_elements":[]}]},"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","turnId":"019ea9a8-2025-7de2-bb4b-ecd86a568956","startedAtMs":1780962828332}}}
@@ -139,8 +133,8 @@
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":0,"windowDurationMins":300,"resetsAt":1780968999},"secondary":{"usedPercent":3,"windowDurationMins":10080,"resetsAt":1781296757},"credits":null,"individualLimit":null,"planType":"pro","rateLimitReachedType":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","status":{"type":"idle"}}}}
{"type":"emit_inbound","label":"turn/completed","frame":{"method":"turn/completed","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","turn":{"id":"019ea9a8-2025-7de2-bb4b-ecd86a568956","items":[],"itemsView":"notLoaded","status":"completed","error":null,"startedAt":1780962828,"completedAt":1780962829,"durationMs":1313}}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":12,"method":"turn/start","params":{"input":[{"text":"Return the source marker followed by both transferred fork markers in merge order, separated by single | characters. Respond with only the markers and separators.","type":"text"}],"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce"}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":12,"result":{"turn":{"id":"019ea9a8-254b-7e53-af1e-1066f8bc37a4","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"expect_outbound","label":"turn/start","frame":{"id":10,"method":"turn/start","params":{"input":[{"text":"Return the source marker followed by both transferred fork markers in merge order, separated by single | characters. Respond with only the markers and separators.","type":"text"}],"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce"}}}
{"type":"emit_inbound","label":"turn/start","frame":{"id":10,"result":{"turn":{"id":"019ea9a8-254b-7e53-af1e-1066f8bc37a4","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","status":{"type":"active","activeFlags":[]}}}}
{"type":"emit_inbound","label":"turn/started","frame":{"method":"turn/started","params":{"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","turn":{"id":"019ea9a8-254b-7e53-af1e-1066f8bc37a4","items":[],"itemsView":"notLoaded","status":"inProgress","error":null,"startedAt":1780962829,"completedAt":null,"durationMs":null}}}}
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"userMessage","id":"f92dacf3-9750-47d3-937b-8af94a859b87","clientId":null,"content":[{"type":"text","text":"Return the source marker followed by both transferred fork markers in merge order, separated by single | characters. Respond with only the markers and separators.","text_elements":[]}]},"threadId":"019ea9a7-e28f-7c72-96e8-9ca581f225ce","turnId":"019ea9a8-254b-7e53-af1e-1066f8bc37a4","startedAtMs":1780962829651}}}
+6 -23
View File
@@ -50,22 +50,13 @@ import Migration0034 from "./Migrations/034_ProjectionThreadsSnoozed.ts";
import Migration0035 from "./Migrations/035_ProjectionThreadTitleRegeneration.ts";
import Migration0036 from "./Migrations/036_ProjectionThreadsPinned.ts";
import Migration0037 from "./Migrations/037_ProjectionTurnsKeysetIndex.ts";
<<<<<<< HEAD
import Migration0038 from "./Migrations/038_ProjectionThreadsPinOrderKey.ts";
import Migration0039 from "./Migrations/039_ProjectionProjectsDefaultThreadEnvMode.ts";
import Migration0040 from "./Migrations/040_ProjectionProjectFaviconPath.ts";
=======
import Migration026V2 from "./Migrations/026_OrchestrationV2.ts";
<<<<<<< HEAD
>>>>>>> d788fb20eb (Implement orchestration v2 runtime)
=======
import Migration034V2 from "./Migrations/034_OrchestrationV2Subagents.ts";
<<<<<<< HEAD
>>>>>>> 3273fa742b (feat(orchestration-v2): model native subagents)
=======
import Migration033V2 from "./Migrations/033_OrchestrationV2.ts";
import Migration034V2 from "./Migrations/034_OrchestrationV2Subagents.ts";
import Migration035V2 from "./Migrations/035_OrchestrationV2Foundation.ts";
>>>>>>> c4eea8d512 (Map orchestration turns to provider instances)
import Migration036V2 from "./Migrations/036_OrchestrationV2ProviderSessionBindings.ts";
/**
* Migration loader with all migrations defined inline.
@@ -115,21 +106,13 @@ export const migrationEntries = [
[35, "ProjectionThreadTitleRegeneration", Migration0035],
[36, "ProjectionThreadsPinned", Migration0036],
[37, "ProjectionTurnsKeysetIndex", Migration0037],
<<<<<<< HEAD
[38, "ProjectionThreadsPinOrderKey", Migration0038],
[39, "ProjectionProjectsDefaultThreadEnvMode", Migration0039],
[40, "ProjectionProjectFaviconPath", Migration0040],
=======
[38, "OrchestrationV2", Migration026V2],
<<<<<<< HEAD
>>>>>>> d788fb20eb (Implement orchestration v2 runtime)
=======
[39, "OrchestrationV2Subagents", Migration034V2],
<<<<<<< HEAD
>>>>>>> 3273fa742b (feat(orchestration-v2): model native subagents)
=======
[40, "OrchestrationV2Foundation", Migration035V2],
>>>>>>> c4eea8d512 (Map orchestration turns to provider instances)
[41, "OrchestrationV2", Migration033V2],
[42, "OrchestrationV2Subagents", Migration034V2],
[43, "OrchestrationV2Foundation", Migration035V2],
[44, "OrchestrationV2ProviderSessionBindings", Migration036V2],
] as const;
export const migrationManifest = migrationEntries.map(([id, name]) => [id, name] as const);
@@ -46,4 +46,50 @@ layer("033_034_OrchestrationV2", (it) => {
assert.ok(subagentColumns.some((column) => column.name === "child_thread_id"));
}),
);
it.effect("backfills provider-session thread bindings in migration 036", () =>
Effect.gen(function* () {
const sql = yield* SqlClient.SqlClient;
yield* runMigrations({ toMigrationInclusive: 35 });
yield* sql`
INSERT INTO orchestration_v2_projection_provider_sessions (
provider_session_id,
thread_id,
provider,
driver,
provider_instance_id,
status,
model,
updated_at,
payload_json
) VALUES (
'provider-session:shared',
'thread:existing',
'codex',
'codex',
'codex',
'ready',
'gpt-5.4',
'2026-01-01T00:00:00.000Z',
'{}'
)
`;
yield* runMigrations({ toMigrationInclusive: 36 });
const bindings = yield* sql<{
readonly provider_session_id: string;
readonly thread_id: string;
}>`
SELECT provider_session_id, thread_id
FROM orchestration_v2_projection_provider_session_bindings
`;
assert.deepStrictEqual(bindings, [
{
provider_session_id: "provider-session:shared",
thread_id: "thread:existing",
},
]);
}),
);
});
@@ -0,0 +1,27 @@
import * as Effect from "effect/Effect";
import * as SqlClient from "effect/unstable/sql/SqlClient";
export default Effect.gen(function* () {
const sql = yield* SqlClient.SqlClient;
yield* sql`
CREATE TABLE orchestration_v2_projection_provider_session_bindings (
provider_session_id TEXT NOT NULL,
thread_id TEXT NOT NULL,
PRIMARY KEY (provider_session_id, thread_id)
)
`;
yield* sql`
INSERT OR IGNORE INTO orchestration_v2_projection_provider_session_bindings (
provider_session_id,
thread_id
)
SELECT provider_session_id, thread_id
FROM orchestration_v2_projection_provider_sessions
WHERE thread_id IS NOT NULL
`;
yield* sql`
CREATE INDEX orchestration_v2_projection_provider_session_bindings_thread_idx
ON orchestration_v2_projection_provider_session_bindings(thread_id)
`;
});