diff --git a/apps/server/src/orchestration-v2/Orchestrator.ts b/apps/server/src/orchestration-v2/Orchestrator.ts index 0dd862e635..515c38a26a 100644 --- a/apps/server/src/orchestration-v2/Orchestrator.ts +++ b/apps/server/src/orchestration-v2/Orchestrator.ts @@ -1432,6 +1432,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio threadId: command.threadId, ordinal, provider: modelSelection.instanceId, + modelSelection, providerThreadId: queueProviderThread.id, userMessageId: command.messageId, rootNodeId, @@ -1910,6 +1911,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio threadId: command.threadId, ordinal, provider: modelSelection.instanceId, + modelSelection, providerThreadId: providerThread.id, userMessageId: command.messageId, rootNodeId, diff --git a/apps/server/src/orchestration-v2/ProviderAdapterRegistry.ts b/apps/server/src/orchestration-v2/ProviderAdapterRegistry.ts index dd8aefd1ad..797d1e1f9d 100644 --- a/apps/server/src/orchestration-v2/ProviderAdapterRegistry.ts +++ b/apps/server/src/orchestration-v2/ProviderAdapterRegistry.ts @@ -198,17 +198,6 @@ export function makeDriverLayerFromSettings(input: { return Layer.unwrap( Effect.gen(function* () { const settingsService = yield* ServerSettingsService; - yield* settingsService.ready.pipe( - Effect.mapError( - (cause) => - new ProviderAdapterDriverCreateError({ - driver: ProviderDriverKindSchema.make("settings"), - instanceId: ProviderInstanceId.make("settings"), - detail: "Server settings were not ready before building provider adapters.", - cause, - }), - ), - ); const settings = yield* settingsService.getSettings.pipe( Effect.mapError( (cause) => diff --git a/apps/server/src/orchestration-v2/testkit/ClaudeReplayFixtures.integration.test.ts b/apps/server/src/orchestration-v2/testkit/ClaudeReplayFixtures.integration.test.ts index d6b372b30f..e95763442c 100644 --- a/apps/server/src/orchestration-v2/testkit/ClaudeReplayFixtures.integration.test.ts +++ b/apps/server/src/orchestration-v2/testkit/ClaudeReplayFixtures.integration.test.ts @@ -118,6 +118,19 @@ describe("Claude Agent SDK replay fixtures", () => { ); provider.assertOutput(result, transcript); + const projectionThreadId = materialized.projectionThreadIds[0]; + if (projectionThreadId === undefined) { + throw new Error("Missing replay projection thread id."); + } + const projection = result.projections.get(projectionThreadId); + if (projection === undefined) { + throw new Error("Missing replay projection."); + } + const latestRun = projection.runs.at(-1); + if (latestRun === undefined) { + throw new Error("Missing replay run."); + } + assert.deepEqual(latestRun.modelSelection, provider.modelSelection); } finally { await rm(checkpointWorkspace, { recursive: true, force: true }); } diff --git a/apps/web/src/routes/debug.orchestration-v2.tsx b/apps/web/src/routes/debug.orchestration-v2.tsx index ec7d27b7af..a571fc4003 100644 --- a/apps/web/src/routes/debug.orchestration-v2.tsx +++ b/apps/web/src/routes/debug.orchestration-v2.tsx @@ -1,4 +1,5 @@ import { + ProviderDriverKind, ProviderInstanceId, type CheckpointId, type CheckpointScopeId, @@ -16,14 +17,17 @@ import { type OrchestrationV2UserInputQuestion, type RunId, type RuntimeMode, + type ServerProvider, type ThreadId, } from "@t3tools/contracts"; import { createFileRoute } from "@tanstack/react-router"; import type { CSSProperties, DragEvent, ReactNode } from "react"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { ProviderModelPicker } from "../components/chat/ProviderModelPicker"; import { getPrimaryEnvironmentConnection } from "../environments/runtime"; import { newCommandId, newMessageId, newProjectId, newThreadId } from "../lib/utils"; +import { deriveProviderInstanceEntries, sortProviderInstanceEntries } from "../providerInstances"; import { GitMergeIcon } from "lucide-react"; export const Route = createFileRoute("/debug/orchestration-v2")({ @@ -31,11 +35,112 @@ export const Route = createFileRoute("/debug/orchestration-v2")({ }); const DEFAULT_PROMPT = "Respond with the following text: fixture simple ok"; +const DEBUG_CODEX_DRIVER = ProviderDriverKind.make("codex"); +const DEBUG_CLAUDE_DRIVER = ProviderDriverKind.make("claudeAgent"); +const DEBUG_CODEX_INSTANCE_ID = ProviderInstanceId.make("codex"); +const DEBUG_CLAUDE_INSTANCE_ID = ProviderInstanceId.make("claudeAgent"); const DEFAULT_MODEL_SELECTION = { - instanceId: ProviderInstanceId.make("codex"), + instanceId: DEBUG_CODEX_INSTANCE_ID, model: "gpt-5.4", } satisfies ModelSelection; +const DEBUG_PROVIDER_SNAPSHOTS: ReadonlyArray = [ + { + instanceId: DEBUG_CODEX_INSTANCE_ID, + driver: DEBUG_CODEX_DRIVER, + displayName: "Codex", + enabled: true, + installed: true, + version: null, + status: "ready", + auth: { status: "authenticated" }, + checkedAt: "2026-01-01T00:00:00.000Z", + models: [ + { + slug: "gpt-5.4", + name: "GPT-5.4", + shortName: "5.4", + isCustom: false, + capabilities: null, + }, + { + slug: "gpt-5.4-mini", + name: "GPT-5.4 Mini", + shortName: "5.4 Mini", + isCustom: false, + capabilities: null, + }, + { + slug: "gpt-5.3-codex", + name: "GPT-5.3 Codex", + shortName: "5.3", + isCustom: false, + capabilities: null, + }, + { + slug: "gpt-5.3-codex-spark", + name: "GPT-5.3 Codex Spark", + shortName: "Spark", + isCustom: false, + capabilities: null, + }, + ], + slashCommands: [], + skills: [], + }, + { + instanceId: DEBUG_CLAUDE_INSTANCE_ID, + driver: DEBUG_CLAUDE_DRIVER, + displayName: "Claude", + enabled: true, + installed: true, + version: null, + status: "ready", + auth: { status: "authenticated" }, + checkedAt: "2026-01-01T00:00:00.000Z", + models: [ + { + slug: "claude-opus-4-7", + name: "Claude Opus 4.7", + shortName: "Opus 4.7", + isCustom: false, + capabilities: null, + }, + { + slug: "claude-opus-4-6", + name: "Claude Opus 4.6", + shortName: "Opus 4.6", + isCustom: false, + capabilities: null, + }, + { + slug: "claude-sonnet-4-6", + name: "Claude Sonnet 4.6", + shortName: "Sonnet 4.6", + isCustom: false, + capabilities: null, + }, + { + slug: "claude-haiku-4-5", + name: "Claude Haiku 4.5", + shortName: "Haiku 4.5", + isCustom: false, + capabilities: null, + }, + ], + slashCommands: [], + skills: [], + }, +]; + +const DEBUG_PROVIDER_INSTANCE_ENTRIES = sortProviderInstanceEntries( + deriveProviderInstanceEntries(DEBUG_PROVIDER_SNAPSHOTS), +); + +const DEBUG_MODEL_OPTIONS_BY_INSTANCE = new Map( + DEBUG_PROVIDER_SNAPSHOTS.map((provider) => [provider.instanceId, provider.models] as const), +); + type LogEntry = | { readonly type: "command"; @@ -233,7 +338,7 @@ function buildProjectionTimeline( key: `run:${run.id}`, eyebrow: "Run", title: `Run ${run.ordinal}`, - subtitle: run.provider, + subtitle: `${run.modelSelection.instanceId} / ${run.modelSelection.model}`, status: run.status, timestamp: formatTimestamp(run.startedAt ?? run.requestedAt), raw: run, @@ -587,6 +692,7 @@ type PendingMergeBackTransfer = OrchestrationV2ThreadProjection["contextTransfer interface DebugThreadTreeNode { readonly threadId: ThreadId; readonly thread: OrchestrationV2ThreadShell; + readonly modelSelection: ModelSelection; readonly children: ReadonlyArray; } @@ -753,6 +859,7 @@ function threadShellCreatedMs(thread: OrchestrationV2ThreadShell): number { function buildThreadTree(input: { readonly threads: ReadonlyMap; + readonly projectionsByThread: ReadonlyMap; }): ReadonlyArray { const childIds = new Map>(); const rootIds: Array = []; @@ -783,10 +890,12 @@ function buildThreadTree(input: { if (thread === undefined) { throw new Error(`Missing orchestration V2 shell thread ${threadId}`); } + const latestRun = input.projectionsByThread.get(threadId)?.runs.at(-1); const children = sortThreadIds(childIds.get(threadId) ?? []).map(buildNode); return { threadId, thread, + modelSelection: latestRun?.modelSelection ?? thread.modelSelection, children, }; }; @@ -1126,8 +1235,8 @@ function ThreadTreeRow(props: { const thread = props.node.thread; const active = props.node.threadId === props.activeThreadId; const relationship = thread.lineage.relationshipToParent ?? "source"; - const instanceId = thread.modelSelection.instanceId; - const model = thread.modelSelection.model; + const instanceId = props.node.modelSelection.instanceId; + const model = props.node.modelSelection.model; const itemCount = thread.visibleItemCount; const createdAt = formatTimestamp(thread.createdAt); @@ -1398,6 +1507,7 @@ function PanelHeader(props: { function OrchestrationV2DebugRoute() { const [prompt, setPrompt] = useState(DEFAULT_PROMPT); + const [modelSelection, setModelSelection] = useState(DEFAULT_MODEL_SELECTION); const [threadId, setThreadId] = useState(null); const [projection, setProjection] = useState(null); const [projectionError, setProjectionError] = useState(null); @@ -1450,8 +1560,8 @@ function OrchestrationV2DebugRoute() { [logEntries, projection, projectionByThread], ); const threadTree = useMemo( - () => buildThreadTree({ threads: shellThreadsById }), - [shellThreadsById], + () => buildThreadTree({ threads: shellThreadsById, projectionsByThread: projectionByThread }), + [projectionByThread, shellThreadsById], ); const activeTurn = useMemo(() => deriveActiveTurn(projection), [projection]); const queuedRuns = useMemo(() => buildQueuedRunRows(projection), [projection]); @@ -1582,7 +1692,7 @@ function OrchestrationV2DebugRoute() { threadId: nextThreadId, projectId: newProjectId(), title: "V2 debug thread", - modelSelection: DEFAULT_MODEL_SELECTION, + modelSelection, runtimeMode: "full-access" satisfies RuntimeMode, interactionMode: "default", branch: null, @@ -1594,7 +1704,7 @@ function OrchestrationV2DebugRoute() { appendLog({ type: "command", label: "thread.create", value: result }); await refreshProjection(nextThreadId); return nextThreadId; - }, [api, appendLog, refreshProjection, subscribeToThread]); + }, [api, appendLog, modelSelection, refreshProjection, subscribeToThread]); const ensureThread = useCallback(async () => { if (threadId !== null) { @@ -1637,7 +1747,7 @@ function OrchestrationV2DebugRoute() { messageId: newMessageId(), text: trimmedPrompt, attachments: [], - modelSelection: DEFAULT_MODEL_SELECTION, + modelSelection, dispatchMode: intent === "steer" && targetRunId !== undefined ? { type: "steer_active", targetRunId } @@ -1660,7 +1770,16 @@ function OrchestrationV2DebugRoute() { setIsBusy(false); } }, - [activeTurn?.targetRunId, api, appendLog, ensureThread, isBusy, prompt, refreshProjection], + [ + activeTurn?.targetRunId, + api, + appendLog, + ensureThread, + isBusy, + modelSelection, + prompt, + refreshProjection, + ], ); const promoteQueuedRun = useCallback( @@ -1917,6 +2036,20 @@ function OrchestrationV2DebugRoute() {
+ { + setModelSelection({ instanceId, model }); + }} + />