[Bug] Claude: switching a running thread to Full access doesn't take effect; MCP orchestrator can't see or answer approval requests #22147
T3 Code 0.0.46-nightly.20261009.2861, macOS arm64, Claude provider.
1. Full access mid-session has no effect
A Claude thread started in Auto or Auto-accept edits is spawned with --permission-mode <mode> but without --allow-dangerously-skip-permissions (confirmed via ps). Switching it to Full access in the composer therefore can't turn off prompts: the SDK refuses to switch into bypassPermissions mid-session (see #1818). The UI shows Full access while approval prompts keep coming.
Expected: either always spawn with --allow-dangerously-skip-permissions (it only allows switching later), or restart the session with the flag when entering Full access, and show the real effective mode.
2. Approval requests are invisible over the orchestrator MCP
t3_pending_request_listleaves out approval requests.t3_pending_request_respondcan't approve them.pendingRequestCountin thread state reads 0 while an approval is open.
The only signal is an approval_request item in the t3_thread_read activity view. An agent that launched a thread can't tell the thread is blocked, so unattended threads hang for hours. Ours hung for 7.5 hours on a single Write to a sibling worktree under acceptEdits.
Request: add pendingApprovalCount to thread state and a tool that lists approvals, and optionally let an MCP caller answer approvals within its own approved permission mode.
t3dotgg(GitHub profile, opens in a new tab) closed this
Tested current main e07595714a on Linux x86_64 in the real web dev app, Claude Opus 5.5, with isolated state.
- In Auto-accept edits, Write to an outside-workspace path opened an approval. Selecting Full access alone changed the composer draft; the server thread stayed in Auto-accept edits. Sending a follow-up applied Full access, restarted the session, and the write completed without another approval. The old run showed a provider-stream-closed error during the restart; that interruption is tracked separately in #23082.
- Auto completed a separate write. Returning to Auto-accept edits and writing a sibling path opened another approval.
- While that approval was open, real MCP calls returned
pendingRequestCount: 1,t3_pending_request_list: {"requestIds":[]}, and an activity item withtype: "approval_request", status: "waiting". The zero count did not reproduce. The pending-request tools explicitly cover questions only; approval answering was reverted in 2bc2d80e79. Delegated waits already exposependingApprovalsince 6f891541fd.
On the latest nightly, does Full access still prompt after sending the next message, or does
t3_thread_readstill return a zero count while approval is open? If either persists, please include the exact nightly/Claude versions and the provider log around the mode change (query.close,query.openoptions andsystem/initpermission mode). The reported macOS arm64 setup was not available here.Captures (Chromium, 1280×800):
Auto-accept edits approval:

Full access selected before sending:

After sending, write completed:

MCP read-only probe while sibling-path approval was open:

juliusmarminge added labelsneeds more info
juliusmarminge reopened this
Retested on 0.1.2-nightly.20261021.3499 (Claude Code 2.1.308, macOS arm64).
An Auto-accept edits thread writing to a sibling path outside its workspace opens an approval ("Path is outside allowed working directories"). That's expected, since acceptEdits only auto-approves edits inside the working directory. While it waits:
t3_thread_read→pendingRequestCount: 1. The zero count no longer reproduces.t3_pending_request_list→{"requestIds":[]}, as documented.- The approval only appears as an
approval_request/waitingactivity item.
Full access applying on the next send matches what @juliusmarminge described, so I'm treating that part as working as designed.
What's left is narrower than my original report. An orchestrator can tell a launched thread is blocked, the same way
t3 threaddoes (pendingRequestCount > 0after a timed-out wait slice). But it can't tell an approval from a question, or which request it is, without inferring it from an empty question list. Delegated tasks already get this throughpendingApproval(#20037); threads started witht3_thread_launchdon't.Proposed fix#
Report the same identity-only
pendingApproval: { requestId, kind, runId } | nullont3_thread_read(OrchestratorMcpThreadDetail) andt3_thread_wait(OrchestratorMcpThreadWaitResult). It is the oldest pending live approval of any unfinished run in the thread.- No way to answer approvals. Pending request tools stay questions-only, so the #22152 boundary is unchanged.
- Wait semantics are unchanged.
t3_thread_waitstill ends only on a terminal run. - Backward compatible. Both fields are optional, so older servers stay compatible.
- Delegated tasks behave the same.
pendingTaskApprovalis generalized intooldestPendingApproval(projection, ownsRun), with no change to how delegated tasks are reported. - Cost.
nodesare loaded only when a pending live approval exists. A plain read adds no load, and a wait adds oneruntimeRequestsread. - New visibility.
requestIdbecomes visible to any caller allowed to read the thread. The activity view shows the request but not its id. Delegated tasks already expose this to their parent.
The patch touches 4 files: the server and contracts change, a unit test and a docs note. The test covers:
- the oldest approval wins;
- an approval on a finished run is ignored, as are a resolved approval, a question and a message-capability request;
- no
nodesload without an approval; - the wait reports the approval, and a quiet wait returns
null.
It fails on main and passes with the change. Checks run on top of main 3b95e7831:
- the MCP tests (225);
- the contracts tests;
- server and contracts typecheck;
- lint and fmt.
I haven't yet tested it end to end against a dev server with a real Claude thread. I'd do that before opening the PR.
Per CONTRIBUTING, I'd rather check first: would you take this as a PR? Happy to adjust the scope. One example is ending
t3_thread_waitearly on an approval, asdelegate_taskdoes inmode=wait, either here or as a follow-up.Patch (against main 3b95e7831)
diff --git a/apps/server/src/mcp/OrchestratorMcpService.activity.test.ts b/apps/server/src/mcp/OrchestratorMcpService.activity.test.ts index 9d2f10bc6..94af95ab5 100644 --- a/apps/server/src/mcp/OrchestratorMcpService.activity.test.ts +++ b/apps/server/src/mcp/OrchestratorMcpService.activity.test.ts @@ -6,7 +6,9 @@ import { ProjectId, ProviderDriverKind, ProviderInstanceId, + ProviderSessionId, RunId, + RuntimeRequestId, ScheduledTaskId, ThreadId, } from "@t3tools/contracts"; @@ -181,6 +183,143 @@ it("readThread prefers activity-run status over a newer cancelled queued run", a }).pipe(Effect.provide(layer), Effect.runPromise); }); +it("readThread and waitForThread name the oldest live approval of an unfinished run", async () => { + const finishedRunId = RunId.make("run-mcp-finished"); + const activeNodeId = NodeId.make("node-mcp-active"); + const finishedNodeId = NodeId.make("node-mcp-finished"); + const live = { type: "live" as const, providerSessionId: ProviderSessionId.make("session-live") }; + const request = ( + id: string, + nodeId: NodeId, + kind: string, + createdAt: string, + responseCapability: object = live, + status: "pending" | "resolved" = "pending", + ) => ({ + id: RuntimeRequestId.make(id), + nodeId, + providerTurnId: null, + nativeRequestRef: null, + kind, + status, + responseCapability, + createdAt: DateTime.makeUnsafe(createdAt), + resolvedAt: null, + }); + const projection = { + thread: baseThread({ + threadId: parentThreadId, + title: "Parent", + instanceId: parentInstanceId, + model: "gpt-5.4", + }), + runs: [ + makeRun({ id: finishedRunId, ordinal: 1, status: "completed" }), + makeRun({ id: activeRunId, ordinal: 2, status: "running" }), + ], + nodes: [ + { id: activeNodeId, runId: activeRunId }, + { id: finishedNodeId, runId: finishedRunId }, + ], + visibleTurnItems: [], + runtimeRequests: [ + // Outlived its finished run's provider callback. + request("request-stale", finishedNodeId, "command", "2026-08-04T11:00:00.000Z"), + request( + "request-answered", + activeNodeId, + "command", + "2026-08-04T11:05:00.000Z", + live, + "resolved", + ), + request("request-question", activeNodeId, "user_input", "2026-08-04T11:10:00.000Z"), + request("request-message", activeNodeId, "command", "2026-08-04T11:20:00.000Z", { + type: "message", + }), + request("request-newer", activeNodeId, "command", "2026-08-04T11:40:00.000Z"), + request("request-oldest", activeNodeId, "file-change", "2026-08-04T11:30:00.000Z"), + ], + messages: [], + contextTransfers: [], + subagents: [], + updatedAt: now, + } as unknown as OrchestrationV2ThreadProjection; + const loadedKinds: Array<ReadonlyArray<string>> = []; + + const layer = layerOrchestratorService.pipe( + Layer.provide( + Layer.mergeAll( + Layer.mock(ThreadManagementService.ThreadManagementService)({ + getTimelinePage: () => Effect.succeed({ items: [], totalItems: 0, hasMore: false }), + getThreadRecords: (threadId, kinds) => { + loadedKinds.push(kinds); + return threadId === parentThreadId + ? Effect.succeed(projection) + : Effect.die(`unexpected thread ${threadId}`); + }, + getThreadShell: (threadId) => + Effect.succeed( + threadId === parentThreadId + ? (projection.thread as unknown as OrchestrationV2ThreadShell) + : null, + ), + getProjectThreadRecords: (input) => + input.threadId === parentThreadId + ? Effect.succeed(projection) + : Effect.die(`unexpected thread ${input.threadId}`), + waitForThread: (input) => + Effect.succeed({ + threadId: input.threadId, + run: projection.runs[1]!, + timedOut: true, + }), + } satisfies Partial<ThreadManagementService.ThreadManagementService["Service"]>), + ServerSettings.layerTest(), + Layer.mock(ProviderRegistry.ProviderRegistry)({ + getProviders: Effect.succeed([]), + } satisfies Partial<ProviderRegistry.ProviderRegistry["Service"]>), + Layer.mock(ProjectService.ProjectService)({}), + Layer.mock(SecretRequests.SecretRequests)({}), + Layer.mock(ScheduledTaskService.ScheduledTaskService)({ + list: () => Effect.succeed({ tasks: [] }), + } satisfies Partial<ScheduledTaskService.ScheduledTaskService["Service"]>), + Layer.mock(ProviderAdapterRegistry.ProviderAdapterRegistryV2)({ + list: () => Effect.succeed([]), + } satisfies Partial<ProviderAdapterRegistry.ProviderAdapterRegistryV2["Service"]>), + NodeCrypto.layer, + ), + ), + ); + + await Effect.gen(function* () { + const service = yield* OrchestratorMcpService.OrchestratorMcpService; + const expected = { + requestId: RuntimeRequestId.make("request-oldest"), + kind: "file-change", + runId: activeRunId, + }; + const read = yield* service.readThread(makeScope(), { threadId: parentThreadId }); + expect(read.thread.pendingRequestCount).toBe(5); + expect(read.thread.pendingApproval).toEqual(expected); + const waited = yield* service.waitForThread(makeScope(), { threadId: parentThreadId }); + expect(waited).toMatchObject({ status: "running", timedOut: true, pendingApproval: expected }); + expect(loadedKinds.some((kinds) => kinds.includes("nodes"))).toBe(true); + + loadedKinds.length = 0; + const withoutApproval = projection.runtimeRequests.filter( + (candidate) => candidate.kind === "user_input", + ); + (projection as { runtimeRequests: unknown }).runtimeRequests = withoutApproval; + const quiet = yield* service.readThread(makeScope(), { threadId: parentThreadId }); + expect(quiet.thread.pendingRequestCount).toBe(1); + expect(quiet.thread.pendingApproval).toBeNull(); + const quietWait = yield* service.waitForThread(makeScope(), { threadId: parentThreadId }); + expect(quietWait.pendingApproval).toBeNull(); + expect(loadedKinds.some((kinds) => kinds.includes("nodes"))).toBe(false); + }).pipe(Effect.provide(layer), Effect.runPromise); +}); + it("taskStatus returns task.providerInstanceId rather than the driver kind", async () => { const parentProjection = { thread: baseThread({ diff --git a/apps/server/src/mcp/OrchestratorMcpService.ts b/apps/server/src/mcp/OrchestratorMcpService.ts index edaa8777b..886cf7698 100644 --- a/apps/server/src/mcp/OrchestratorMcpService.ts +++ b/apps/server/src/mcp/OrchestratorMcpService.ts @@ -7,6 +7,7 @@ import { NodeId, TurnItemId, type OrchestrationV2Run, + type OrchestrationV2RuntimeRequest, type OrchestrationV2Subagent, type OrchestrationV2ThreadProjection, type OrchestrationV2ThreadShell, @@ -22,6 +23,7 @@ import { type OrchestratorMcpDelegateTaskInput, type OrchestratorMcpDelegateTaskResult, type OrchestratorMcpInteractionMode, + type OrchestratorMcpPendingApproval, type OrchestratorMcpDeleteScheduledTaskInput, type OrchestratorMcpRequestSecretInput, type OrchestratorMcpRequestSecretResult, @@ -508,34 +510,31 @@ function endsTaskWait(result: OrchestratorMcpDelegateTaskResult): boolean { const isApprovalRequestKind = Schema.is(ProviderRequestKind); -function pendingTaskApproval( - child: Pick<OrchestrationV2ThreadProjection, "runs" | "nodes" | "runtimeRequests">, - taskId: NodeId, - originalRun: OrchestrationV2Run | undefined, -) { - const taskRunIds = new Set( - child.runs - .filter( - (run) => - !ThreadManagementService.isTerminalRunStatus(run.status) && - (run.delegatedTaskId === taskId || - // Legacy tasks own only their original run, not later turns in the child thread. - (run.delegatedTaskId === undefined && run.id === originalRun?.id)), - ) +function isPendingLiveApproval( + request: OrchestrationV2RuntimeRequest, +): request is OrchestrationV2RuntimeRequest & { readonly kind: ProviderRequestKind } { + return ( + request.status === "pending" && + request.responseCapability.type === "live" && + isApprovalRequestKind(request.kind) + ); +} + +function oldestPendingApproval( + projection: Pick<OrchestrationV2ThreadProjection, "runs" | "nodes" | "runtimeRequests">, + ownsRun: (run: OrchestrationV2Run) => boolean, +): OrchestratorMcpPendingApproval | null { + const runIds = new Set( + projection.runs + .filter((run) => !ThreadManagementService.isTerminalRunStatus(run.status) && ownsRun(run)) .map((run) => run.id), ); - let approval: OrchestratorMcpDelegateTaskResult["pendingApproval"] = null; + let approval: OrchestratorMcpPendingApproval | null = null; let oldestCreatedAt = Infinity; - for (const request of child.runtimeRequests) { - if ( - request.status !== "pending" || - request.responseCapability.type !== "live" || - !isApprovalRequestKind(request.kind) - ) { - continue; - } - const runId = child.nodes.find((node) => node.id === request.nodeId)?.runId; - if (runId === undefined || runId === null || !taskRunIds.has(runId)) continue; + for (const request of projection.runtimeRequests) { + if (!isPendingLiveApproval(request)) continue; + const runId = projection.nodes.find((node) => node.id === request.nodeId)?.runId; + if (runId === undefined || runId === null || !runIds.has(runId)) continue; const createdAt = DateTime.toEpochMillis(request.createdAt); if (createdAt < oldestCreatedAt) { oldestCreatedAt = createdAt; @@ -545,6 +544,20 @@ function pendingTaskApproval( return approval; } +function pendingTaskApproval( + child: Pick<OrchestrationV2ThreadProjection, "runs" | "nodes" | "runtimeRequests">, + taskId: NodeId, + originalRun: OrchestrationV2Run | undefined, +) { + return oldestPendingApproval( + child, + (run) => + run.delegatedTaskId === taskId || + // Legacy tasks own only their original run, not later turns in the child thread. + (run.delegatedTaskId === undefined && run.id === originalRun?.id), + ); +} + function directAppOwnedChildTasks( parent: Pick<OrchestrationV2ThreadProjection, "thread" | "subagents">, target: Pick<OrchestrationV2ThreadProjection, "thread" | "runs">, @@ -889,6 +902,7 @@ function threadDetail( itemCount: number, shell: OrchestrationV2ThreadShell, nowMs: number, + pendingApproval: OrchestratorMcpPendingApproval | null, ): OrchestratorMcpThreadDetail { const latest = ThreadManagementService.latestRun(projection); const active = ThreadManagementService.latestActiveRun(projection); @@ -924,6 +938,7 @@ function threadDetail( pendingRequestCount: projection.runtimeRequests.filter( (request) => request.status === "pending", ).length, + pendingApproval, archived: projection.thread.archivedAt !== null, ...threadSettlement(projection.thread), ...threadSnooze(shell, nowMs), @@ -1223,6 +1238,22 @@ const make = Effect.gen(function* () { return { ...caller, target } as const; }); + // Nodes are only loaded when a live approval is pending, to keep plain reads cheap. + const threadPendingApproval = ( + threadId: ThreadId, + runtimeRequests: ReadonlyArray<OrchestrationV2RuntimeRequest>, + ) => + runtimeRequests.some(isPendingLiveApproval) + ? threadManagement + .getThreadRecords(threadId, ["runs", "nodes", "runtimeRequests"], { + omitSettledLeafNodes: true, + }) + .pipe( + Effect.map((current) => oldestPendingApproval(current, () => true)), + Effect.mapError(threadManagementFailure), + ) + : Effect.succeed(null); + /** * A thread caller writes to another thread only while its own run is live, * so a credential that outlived its session cannot reach across threads. @@ -2804,7 +2835,13 @@ const make = Effect.gen(function* () { } } return { - thread: threadDetail(target, timeline.totalItems, shell, yield* Clock.currentTimeMillis), + thread: threadDetail( + target, + timeline.totalItems, + shell, + yield* Clock.currentTimeMillis, + yield* threadPendingApproval(target.thread.id, target.runtimeRequests), + ), recentRuns: target.runs .toSorted((left, right) => right.ordinal - left.ordinal) .slice(0, input.runLimit ?? DEFAULT_THREAD_RUN_LIMIT) @@ -2888,6 +2925,12 @@ const make = Effect.gen(function* () { runId: result.run?.id ?? null, status: result.run === null ? "idle" : runOutcome(result.run), timedOut: result.timedOut, + pendingApproval: yield* threadPendingApproval( + input.threadId, + (yield* threadManagement + .getThreadRecords(input.threadId, ["runtimeRequests"]) + .pipe(Effect.mapError(threadManagementFailure))).runtimeRequests, + ), } satisfies OrchestratorMcpThreadWaitResult; }), interruptThread: Effect.fn("OrchestratorMcpService.interruptThread")(function* (scope, input) { diff --git a/docs/orchestration-v2/orchestrator-mcp-server.md b/docs/orchestration-v2/orchestrator-mcp-server.md index 5f312b61b..34ad9546b 100644 --- a/docs/orchestration-v2/orchestrator-mcp-server.md +++ b/docs/orchestration-v2/orchestrator-mcp-server.md @@ -402,6 +402,11 @@ client's `effectiveSnoozed`, so agents and the sidebar agree: a snoozed thread wakes early only when it has a pending request or fails after snoozing. Completed runs, background wakes, and delegated completions keep it snoozed. +`pendingRequestCount` counts questions and approvals alike. Thread detail also +reports `pendingApproval`: the identity of the oldest pending live approval of an +unfinished run, or `null`, in the same identity-only shape as delegated tasks. It +grants no approval authority, and pending request tools still answer questions only. + ### `t3_thread_update` Updates metadata for the calling thread or any other thread in the environment. @@ -436,7 +441,9 @@ idempotent retries. Waits for a selected run to become `completed`, `failed`, `cancelled`, `interrupted`, or `rolled_back`. Without `runId`, it pins the latest run at call time; an idle thread returns immediately. A timeout reports the latest durable -status and does not cancel work. +status and does not cancel work. The result also reports `pendingApproval` as in +`t3_thread_read`, so a caller can tell a run blocked on an approval from one that +is still working. A pending approval does not end the wait. ### `t3_thread_interrupt` diff --git a/packages/contracts/src/orchestratorMcp.ts b/packages/contracts/src/orchestratorMcp.ts index c962c3975..49c78b1db 100644 --- a/packages/contracts/src/orchestratorMcp.ts +++ b/packages/contracts/src/orchestratorMcp.ts @@ -191,6 +191,14 @@ export const OrchestratorMcpDelegateTaskInput = Schema.Struct({ }); export type OrchestratorMcpDelegateTaskInput = typeof OrchestratorMcpDelegateTaskInput.Type; +/** Identity only: holds no request details and grants no approval authority. */ +export const OrchestratorMcpPendingApproval = Schema.Struct({ + requestId: RuntimeRequestId, + kind: ProviderRequestKind, + runId: RunId, +}); +export type OrchestratorMcpPendingApproval = typeof OrchestratorMcpPendingApproval.Type; + export const OrchestratorMcpDelegateTaskResult = Schema.Struct({ taskId: NodeId, childThreadId: ThreadId, @@ -217,9 +225,7 @@ export const OrchestratorMcpDelegateTaskResult = Schema.Struct({ description: "Blocking question ends mode=wait. Pass threadId=childThreadId to t3_pending_request_list, t3_pending_request_read (with requestId) and t3_pending_request_respond, or ask the user; the task's completion still wakes this thread.", }), - pendingApproval: Schema.NullOr( - Schema.Struct({ requestId: RuntimeRequestId, kind: ProviderRequestKind, runId: RunId }), - ).annotate({ + pendingApproval: Schema.NullOr(OrchestratorMcpPendingApproval).annotate({ description: "Identity of the oldest pending live approval for this task's own unfinished work, or null. Ends mode=wait without cancelling the child; completion still wakes this thread. This grants no approval authority. Read the fresh full request in childThreadId before responding: the record can outlive its provider callback. Decisions remain with the child's existing approval holder; pending request tools answer questions only.", }), @@ -419,6 +425,13 @@ export const OrchestratorMcpThreadDetail = Schema.Struct({ runCount: NonNegativeInt, itemCount: NonNegativeInt, pendingRequestCount: NonNegativeInt, + /** Missing on older servers. */ + pendingApproval: Schema.optional( + Schema.NullOr(OrchestratorMcpPendingApproval).annotate({ + description: + "Identity of the oldest pending live approval for this thread's unfinished runs, or null. pendingRequestCount also counts it. This grants no approval authority; pending request tools answer questions only, and the record can outlive its provider callback.", + }), + ), archived: Schema.Boolean, settled: Schema.Boolean, settledAt: Schema.NullOr(IsoDateTime), @@ -501,6 +514,13 @@ export const OrchestratorMcpThreadWaitResult = Schema.Struct({ runId: Schema.NullOr(RunId), status: OrchestratorMcpThreadStatus, timedOut: Schema.Boolean, + /** Missing on older servers. */ + pendingApproval: Schema.optional( + Schema.NullOr(OrchestratorMcpPendingApproval).annotate({ + description: + "Identity of the oldest pending live approval for this thread's unfinished runs when the wait returned, or null. A run blocked on it keeps running until someone with approval authority answers it. Grants no approval authority.", + }), + ), }); export type OrchestratorMcpThreadWaitResult = typeof OrchestratorMcpThreadWaitResult.Type;juliusmarminge removed labelsneeds more info
Sign in to join this conversation.
Note
🤖 Claude Opus 5.5 responding on behalf of Theo
Thanks for the report. One part of this is fixed on main in #20037. Please test on the nightly built from main on 2026-10-21, or on the next stable release. One part is still open: t3_pending_request_list and pendingRequestCount still omit approvals; MCP approval responses remain reverted, and switching a running Claude session to Full access is not addressed. If that part still matters to you, please open a new issue for that part only.