Skip to content
Source
Sign inSign up
pingdotgg/t3code

t3_environment_preferences_update always fails: ThreadCommandExecutor is not provided to MCP tool handlers #15131

Closed0pilatos0(GitHub profile, opens in a new tab) opened this issue 2 comments

What happened

t3_environment_preferences_update returns "Tool execution failed due to an internal server error" on every call, even a no-op: re-saving backgroundActivity.profile: "balanced", which was already the current value. The calling thread was full-access/default. A follow-up t3_environment_read shows nothing changed. Reproduces on nightlies .2610 and .2623, desktop app, macOS arm64.

Diagnosis

The handler fails before it reaches the permission check or settings, because ThreadCommandExecutor is never in the context MCP tool calls run in.

  • apps/server/src/mcp/toolkits/environment/handlers.ts:59 yields ThreadCommandExecutor to wrap the update in withLock, and tools.ts:37 lists it in the toolkit's dependencies. It is the only MCP toolkit that does.
  • ThreadCommandExecutor.layer is only provided privately, via Layer.provide: to the provider event ingestor (orchestration-v2/runtimeLayer.ts:107) and to ProjectService (project/ProjectService.ts:571). Neither exposes it to McpHttpServer.layer (server.ts:647).
  • The lookup dies with Service not found, a defect rather than an OrchestratorMcpFailure, so the client only sees a generic internal error. The lookup sits before access(true) and the full-access check, so the permission check never runs either, and updateSettings is never called.
  • No test calls this handler, so the missing service only shows up at runtime.
  • Unchanged on main as of e8545b29 (2026-10-03).

Possible direction: provide ThreadCommandExecutor to the MCP layer, using the same instance the orchestrator locks on (otherwise the lock serializes nothing), or drop the lock from this handler.

Steps to reproduce

  1. Desktop app, nightly 0.0.46-nightly.20261003.2623 (also .2610).
  2. In a thread with runtime mode full-access and interaction mode default, have the agent call t3_environment_preferences_update with {"backgroundActivity":{"profile":"balanced"}} (the current value is fine).
  3. The tool returns "Tool execution failed due to an internal server error".
  4. t3_environment_read shows no change. server.trace.ndjson has the error below.

Version

0.0.46-nightly.20261003.2623 (also seen on 0.0.46-nightly.20261003.2610)

Environment

macOS 27.0 (darwin arm64), desktop app (Nightly), Node v26.8.2

Evidence

# server.trace.ndjson, 2026-10-03T10:01:23Z (trimmed)
{"type":"effect-span","name":"McpServer.@effect/mcp/2025-06-18/tools/call","durationMs":2.363,
 "attributes":{"tool":"t3_environment_preferences_update","parameters":{"backgroundActivity":{"profile":"balanced"}}},
 "events":[{"attributes":{"effect.logLevel":"ERROR",
   "effect.cause":"Error: Service not found: t3/orchestration-v2/ThreadCommandExecutor\n    at McpServer.@effect/mcp/2025-06-18/tools/call\n    at McpHttpServer.authenticateRequest (file:///Applications/T3%20Code%20(Nightly).app/Contents/Resources/app.asar/apps/server/dist/binCli-CCV0Rnbz.mjs:22316:70)"}}]}

None found. #14991 is also about an MCP settings tool (t3_project_update) but has a different cause: saved values are ignored, not a missing service.

Fix applied or workaround

Nothing changed on the machine. Workaround: change the same preferences in the app under Settings (Background activity, etc.) instead of through the MCP tool.

Filed by

Claude Code (claude-opus-5-5) via t3 triage

  1. Note

    Grok responding on behalf of Julius.

    Triage

    Thanks @0pilatos0 for the precise report and trace! I confirmed this is a bug on current main (263097a8da). t3_environment_preferences_update can't succeed, even for a no-op, while t3_environment_read works fine. This isn't a duplicate of #14991.

    What happens

    The handler in apps/server/src/mcp/toolkits/environment/handlers.ts yields ThreadCommandExecutor before it runs the full-access check or updateSettings. That service isn't in the context MCP tool calls run in, so the lookup fails with Service not found: t3/orchestration-v2/ThreadCommandExecutor. Effect's MCP server turns that into "Tool execution failed due to an internal server error", so settings are never written. Listing the service in the dependencies in tools.ts doesn't provide it. Read never asks for it, which is why read keeps working.

    Why the service is missing

    ThreadCommandExecutor.layer is only provided privately to the orchestrator (Orchestrator.ts), ProjectService (ProjectService.ts), and the provider event ingestor (runtimeLayer.ts). None of them export it, and neither EnvironmentRegistrationLive nor McpHttpServer.layer adds it. Toolkit handlers capture the context that exists when their layer is built. Services merged into the server, like ServerSettings, ServerEnvironment, and ThreadManagement, are there. This executor isn't.

    Those three call sites share one executor instance because they reference the same layer value. That shared lock is what keeps this update's archived, full-access, and default checks from racing an in-flight command on the same thread. Building a second executor would avoid the crash but would not serialize with thread dispatch or project deletion.

    No test calls this handler, so the gap only shows up at runtime. The tool has been broken since it arrived with the orchestrator rewrite in #2829 (merged). Stable v0.0.45 shipped before that and doesn't include the tool. Nightlies .2610 and .2623 do.

    Likely fix area

    Provide the existing ThreadCommandExecutor.layer into the context captured for EnvironmentHandlersLive, so this handler shares the orchestrator's instance. Add a test that calls t3_environment_preferences_update through the production MCP layer without stubbing the executor in. A maintainer will decide on the fix direction.

    #14991 (open) and its open PR #15012 cover a different tool, t3_project_update, and a different failure. Until this is fixed, the same preferences can still be changed in Settings.

  2. juliusmarminge added labelsbug

  3. juliusmarminge added labelsvia-triage

  4. Still reproduces on 0.0.46-nightly.20261005.2702 (desktop, macOS 26.5.2, Apple Silicon). A no-op call from a full-access thread, t3_environment_preferences_update with {"enableProviderUpdateChecks": true}, returns "Tool execution failed due to an internal server error", and the server trace records Error: Service not found: t3/orchestration-v2/ThreadCommandExecutor under McpServer.@effect/mcp/2025-06-18/tools/call. t3_environment_read keeps working.

  5. juliusmarminge closed this

Sign in to join this conversation.