SOURCE INSPECTION ONLY; NOT PROVIDER/TRANSPORT EXECUTION. Numbered immutable Git-object excerpts. S2/S3: unchanged full file across BEFORE eea989536849e5b5049987ee24318b5a77326542 / AFTER c3eda496803eaedb003c5f01e9c7905209325e13 apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts 757: selectedEffort === undefined ? undefined : yield* decodeTurnReasoningEffort(selectedEffort); 758: const serviceTier = 759: input.omitServiceTier === true 760: ? undefined 761: : getCodexServiceTierOptionValue(input.modelSelection); 762: const developerInstructions = 763: input.hasT3Mcp !== true 764: ? undefined 765: : buildCodexDeveloperInstructions(input.runtimePolicy.interactionMode); 766: // An app's context is text an MCP server wrote, so it goes in as untrusted 767: // context: Codex renders it as quoted user-side input, never as developer 768: // instructions. 769: const appContext = Object.fromEntries( 770: (input.appContext ?? []).map((entry) => [ 771: entry.key, 772: { kind: "untrusted" as const, value: entry.text }, 773: ]), 774: ); 775: const t3Context = 776: input.hasT3Mcp === true 777: ? buildCodexAdditionalContext( 778: { model: input.modelSelection.model, reasoningEffort: effort ?? undefined }, 779: { 780: browser: input.browserToolsAvailable ?? true, 781: device: input.deviceToolsAvailable ?? false, 782: }, 783: ) 784: : undefined; 785: const additionalContext = 786: t3Context === undefined && Object.keys(appContext).length === 0 787: ? undefined 788: : { ...t3Context, ...appContext }; 789: const collaborationMode: CodexSchema.ClientRequest__CollaborationMode | undefined = 790: input.runtimePolicy.interactionMode !== "plan" && developerInstructions === undefined 791: ? undefined S4: unchanged full file across BEFORE eea989536849e5b5049987ee24318b5a77326542 / AFTER c3eda496803eaedb003c5f01e9c7905209325e13 apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts 1403: ? { pathToClaudeCodeExecutable: input.settings.binaryPath } 1404: : {}), 1405: ...(input.environment === undefined ? {} : { env: input.environment }), 1406: ...(input.mcpServers === undefined ? {} : { mcpServers: input.mcpServers }), 1407: systemPrompt: { 1408: type: "preset" as const, 1409: preset: "claude_code" as const, 1410: append: [ 1411: buildRuntimeInstructions({ harness: "Claude Code" }) + 1412: (input.mcpServers === undefined ? "" : T3_CODE_ORCHESTRATION_INSTRUCTIONS), 1413: ...launchAppendSystemPrompt, 1414: ].join("\n\n"), 1415: }, 1416: ...(Object.keys(extraArgs).length === 0 ? {} : { extraArgs }), S5: unchanged full file across BEFORE eea989536849e5b5049987ee24318b5a77326542 / AFTER c3eda496803eaedb003c5f01e9c7905209325e13 packages/provider-cursor/src/server/adapter.ts 2215: Effect.provideService(FileSystem.FileSystem, fileSystem), 2216: Effect.provideService(Path.Path, path), 2217: ); 2218: cursorSkillNames = new Set( 2219: skills 2220: .filter((skill) => skill.enabled && skill.userInvocable !== false) 2221: .map((skill) => skill.name), 2222: ); 2223: } 2224: const userText = t3OrchestrationPromptForFirstRun({ 2225: prompt: providerMessageTextWithAttachmentPaths({ 2226: text: 2227: cursorSkillNames === undefined 2228: ? rawText 2229: : rewriteCursorSkillMentions(rawText, cursorSkillNames), 2230: attachments: turnInput.message.attachments, 2231: resolveAttachmentPath: host.resolveAttachmentPath, 2232: }), 2233: runOrdinal: turnInput.runOrdinal, 2234: hasT3Mcp: mcpServers !== undefined, 2235: }); 2236: const images = yield* Effect.forEach( 2237: turnInput.message.attachments.filter(isProviderNativeImageAttachment), 2238: (attachment: ChatAttachment) => 2239: Effect.gen(function* () { S6/S7: unchanged full file across BEFORE eea989536849e5b5049987ee24318b5a77326542 / AFTER c3eda496803eaedb003c5f01e9c7905209325e13 packages/provider-acp/src/server/adapter.ts 3694: : { beforeTokenCount: context.contextUsage.usedTokens }), 3695: }; 3696: if (status === "completed") { 3697: context.contextUsage = null; 3698: yield* Ref.update(contextUsageBySessionId, (current) => { 3699: const updated = new Map(current); 3700: updated.delete(context.nativeThreadId); 3701: return updated; 3702: }); 3703: yield* Ref.update(compactionMarkers, (current) => { 3704: const updated = new Map(current); 3705: updated.set(context.nativeThreadId, Symbol()); 3706: return updated; 3707: }); 7158: const prompt: Array = []; 7159: const instructionState = { 7160: interactionMode: turnInput.runtimePolicy.interactionMode, 7161: hasT3Mcp: (yield* readMcpContext(turnInput.threadId)).servers.length > 0, 7162: } satisfies T3AcpInstructionState; 7163: const previousInstructionState = (yield* Ref.get(promptInstructionStates)).get(sessionId); 7164: const compactionMarker = (yield* Ref.get(compactionMarkers)).get(sessionId); 7165: const messageText = providerMessageTextWithAttachmentPaths({ 7166: text: turnInput.message.text, 7167: attachments: turnInput.message.attachments, 7168: resolveAttachmentPath: host.resolveAttachmentPath, 7169: }); 7170: const isNativeSlashCommand = turnInput.message.text.trimStart().startsWith("/"); 7171: const text = t3AcpPromptWithInstructions({ 7172: prompt: messageText, 7173: state: instructionState, 7174: ...(previousInstructionState === undefined || compactionMarker !== undefined 7175: ? {} 7176: : { previousState: previousInstructionState }), 7177: }); 7178: if (text.length > 0) { 7179: prompt.push({ type: "text", text }); 7180: } S8 legacy: unchanged full file across BEFORE eea989536849e5b5049987ee24318b5a77326542 / AFTER c3eda496803eaedb003c5f01e9c7905209325e13 packages/provider-opencode/src/server/adapter.ts 952: directory: cwd, 953: ...(connection.external && options.settings.serverPassword 954: ? { serverPassword: options.settings.serverPassword } 955: : {}), 956: }); 957: 958: const mcpSession = yield* mcpSessions.read(input.threadId); 959: const hasT3Mcp = mcpSession !== undefined && !connection.external; 960: const orchestrationSystemPrompt = t3OrchestrationSystemPrompt(hasT3Mcp); 961: if (hasT3Mcp) { 984: createdAt: now, 985: updatedAt: now, 986: lastError: null, 987: }; 988: const events = yield* Queue.unbounded(); 989: let nativeStreamFailure: OrchestrationV2ProviderFailure | null = null; 990: const threads = new Map(); 991: const commandReceipts = new Map>(); 992: const commandControllers = new Map>(); 993: const pendingRequests = new Map(); 994: const pendingRequestsByNativeId = new Map(); 995: const subagentsByNativeItemId = new Map(); 996: const subagentsByChildSessionId = new Map(); 997: const relatedSessionOwners = new Map(); 998: // Sessions of this runtime that OpenCode reports busy. A background 999: // task child keeps running after its parent turn settles, so idle 1000: // release must not close the server under it. 1001: const busySessionIds = new Set(); 1002: // Requests settled before their session relation resolved: a late S8 v2: unchanged full file across BEFORE eea989536849e5b5049987ee24318b5a77326542 / AFTER c3eda496803eaedb003c5f01e9c7905209325e13 packages/provider-opencode/src/server/v2/adapter.ts 3136: ); 3137: if (mcpAvailable) state.mcp = wanted; 3138: } 3139: const instructions = [ 3140: buildRuntimeInstructions({ harness: "OpenCode", model: turnInput.modelSelection.model }), 3141: t3OrchestrationSystemPrompt(mcpAvailable), 3142: ] 3143: .filter((part) => part !== undefined && part.length > 0) 3144: .join("\n\n"); 3145: if (instructions !== state.instructions) { 3146: yield* client.session.instructions.entry.put({ 3147: sessionID: Session.ID.make(sessionId), T1/T2 registration: unchanged full file across BEFORE eea989536849e5b5049987ee24318b5a77326542 / AFTER c3eda496803eaedb003c5f01e9c7905209325e13 apps/server/src/mcp/McpHttpServer.ts 409: const decodeAsAdvertised = >( 410: toolkit: Toolkit.Toolkit, 411: ): Toolkit.Toolkit => 412: // The clones keep each tool's id, name and decoded parameter type, so handlers still match. 413: Toolkit.make( 414: ...Object.values(toolkit.tools).map((tool) => 415: tool.setParameters(Schema.toCodecJson(tool.parametersSchema)), 416: ), 417: ) as unknown as Toolkit.Toolkit; 418: 419: const isPreviewAutomationError = Schema.is(PreviewAutomationError); 420: 421: const previewSnapshotFailure = (cause: Cause.Cause) => { 422: if (Cause.hasInterrupts(cause) || cause.reasons.some(Cause.isDieReason)) { 423: return Effect.failCause(cause).pipe(Effect.orDie); 424: } 425: const failures = cause.reasons.filter(Cause.isFailReason); 426: const firstFailure = failures[0]?.error; 427: const errorTag = 428: typeof firstFailure === "object" && 429: firstFailure !== null && 430: "_tag" in firstFailure && 431: typeof firstFailure._tag === "string" 432: ? firstFailure._tag 433: : "PreviewSnapshotError"; 434: // Preview errors build their message on the server, never from page output, 435: // and it tells the agent what to do next, such as falling back to a shell browser. 436: const message = isPreviewAutomationError(firstFailure) ? firstFailure.message : undefined; 437: const result = new McpSchema.CallToolResult({ 438: isError: true, 439: structuredContent: { 955: Effect.forkDetach, 956: Effect.asVoid, 957: ); 958: }), 959: ); 960: }), 961: }), 962: }); 963: return yield* registration.pipe(Effect.provideService(McpServer.McpServer, recordingServer)); 964: }); 965: 966: /** 967: * `McpServer.toolkit` asks for every service its tools declare when it 968: * registers them, but the auth middleware provides `McpInvocationContext` to 969: * each request instead. Registration must not get one: the services it 970: * captures would replace the request's. 971: */ 972: export const toolkitRegistration = , EX, RX>( 973: toolkit: Toolkit.Toolkit, 974: handlers: McpToolAccess.HandlersLayer, 975: ) => { 976: const registration = Layer.effectDiscard( 977: withToolAnalytics(McpServer.registerToolkit(decodeAsAdvertised(toolkit))), 978: ).pipe(Layer.provide(McpServer.McpServer.layer)); 979: // @effect-diagnostics-next-line unsafeEffectTypeAssertion:off - the auth middleware provides it per request. 980: const registered = registration as Layer.Layer< 981: never, 982: never, 983: Exclude, McpInvocationContext.McpInvocationContext> 1016: export const layerOrchestratorToolkit = toolkitRegistration( 1017: OrchestratorToolkit, 1018: OrchestratorHandlers.layer, 1019: ).pipe(Layer.provide(OrchestratorMcpService.layer), Layer.provide(ThreadMetadataMcpService.layer)); 1020: T1/T2 ACP stdio forwarding: unchanged full file across BEFORE eea989536849e5b5049987ee24318b5a77326542 / AFTER c3eda496803eaedb003c5f01e9c7905209325e13 apps/server/src/mcp/AcpMcpStdioBridge.ts 186: const writeMessage = (message: unknown): Effect.Effect => 187: Effect.sync(() => { 188: options.output.write(`${JSON.stringify(message)}\n`); 189: }); 190: 191: const handleServerPayload = Effect.fn("AcpMcpStdioBridge.handleServerPayload")(function* ( 192: payload: unknown, 193: ): Effect.fn.Return { 194: for (const entry of Array.isArray(payload) ? payload : [payload]) { 195: protocolVersion = protocolVersionOf(entry) ?? protocolVersion; 196: yield* writeMessage(entry); 197: } 198: }); 199: 200: const respondWithError = ( 201: requestId: unknown, 202: message: string, 203: code = -32603, 204: ): Effect.Effect => 215: const response = yield* Effect.tryPromise({ 216: try: (signal) => 217: fetchImplementation(options.endpoint, { 218: method: "POST", 219: headers: { 220: "content-type": "application/json", 221: accept: "application/json, text/event-stream", 222: authorization: options.authorization, 223: ...(sessionId === null ? {} : { "mcp-session-id": sessionId }), 224: ...(protocolVersion === null ? {} : { "mcp-protocol-version": protocolVersion }), 225: }, 226: body: line, 227: signal, 228: }), 229: catch: bridgeError, 230: }); 231: sessionId = response.headers.get("mcp-session-id") ?? sessionId; 232: if (!response.ok) { 233: if (envelope.id !== undefined) { 234: yield* respondWithError( 235: envelope.id, 236: `T3 Code MCP endpoint responded with HTTP ${response.status}.`, 237: ); 238: } 239: return yield* discardResponseBody(response); 240: } 241: yield* Stream.runForEach(responsePayloads(response, bridgeError), handleServerPayload); 242: }, 243: (effect, _line, envelope) => S9 BEFORE eea989536849e5b5049987ee24318b5a77326542 packages/provider-pi/src/server/mcpExtensionSource.ts 342: const endpoint = env(URL_ENV); 343: const token = env(TOKEN_ENV); 344: if (endpoint === undefined || token === undefined) { 345: pi.on("session_start", async (_event, ctx) => { 346: ctx.ui.notify( 347: "t3-code MCP unavailable: T3_MCP_URL or T3_MCP_BEARER_TOKEN is missing.", 348: "warning", 349: ); 350: }); 351: return; 352: } 353: 354: // Tool exposure arrived with registerMcpServer in Pi 0.99. Keep the HTTP 355: // bridge as the credential owner: mcp.json overrides native registrations. 458: pi.on("before_agent_start", (event, ctx) => { 459: reconcileDiscovery(ctx); 460: const sections = event.systemPromptOptions?.sections; 461: if (sections && typeof sections === "object" && event.systemPromptOptions?.forceSystemPrompt === undefined) { 462: // A full prompt override bypasses Pi's later section rendering. 463: sections.t3_code_orchestration = ORCHESTRATION_INSTRUCTIONS; 464: return undefined; 465: } 466: return { systemPrompt: event.systemPrompt + "\\n\\n" + ORCHESTRATION_INSTRUCTIONS }; 467: }); 468: } 469: `; 470: S9 AFTER c3eda496803eaedb003c5f01e9c7905209325e13 packages/provider-pi/src/server/mcpExtensionSource.ts 342: const endpoint = env(URL_ENV); 343: const token = env(TOKEN_ENV); 344: if (endpoint === undefined || token === undefined) { 345: pi.on("session_start", async (_event, ctx) => { 346: ctx.ui.notify( 347: "t3-code MCP unavailable: T3_MCP_URL or T3_MCP_BEARER_TOKEN is missing.", 348: "warning", 349: ); 350: }); 351: return; 352: } 353: 354: // Tool exposure arrived with registerMcpServer in Pi 0.99. Keep the HTTP 355: // bridge as the credential owner: mcp.json overrides native registrations. 458: pi.on("before_agent_start", (event, ctx) => { 459: reconcileDiscovery(ctx); 460: const sections = event.systemPromptOptions?.sections; 461: if (sections && typeof sections === "object" && event.systemPromptOptions?.forceSystemPrompt === undefined) { 462: // A full prompt override bypasses Pi's later section rendering. 463: sections.t3_code_orchestration = ORCHESTRATION_INSTRUCTIONS; 464: return undefined; 465: } 466: return { systemPrompt: event.systemPrompt + "\\n\\n" + ORCHESTRATION_INSTRUCTIONS }; 467: }); 468: } 469: `; 470: N1: five changed files are server text/tests, shared instruction text and Markdown only. No UI, client contracts, handler, schema, transport or lifecycle change. N2: runtime connection modes and model selections not executed; output text is independent of them. Named ACP drivers share the inspected adapter. Muse has no direct changed-module import. Scope inventory: M apps/server/src/mcp/McpHttpServer.test.ts M apps/server/src/mcp/toolkits/orchestrator/tools.ts M apps/server/src/provider/CodexDeveloperInstructions.test.ts M docs/orchestration-v2/orchestrator-mcp-server.md M packages/provider-core/src/server/orchestrationInstructions.ts apps/server/src/mcp/McpHttpServer.test.ts | 11 +++++++++++ apps/server/src/mcp/toolkits/orchestrator/tools.ts | 2 +- .../src/provider/CodexDeveloperInstructions.test.ts | 21 +++++++++++++++++++++ docs/orchestration-v2/orchestrator-mcp-server.md | 15 ++++++++------- .../src/server/orchestrationInstructions.ts | 4 ++-- 5 files changed, 43 insertions(+), 10 deletions(-) T1/T2 installed Effect 4.0.5 registration source (dependency inspection, same lockfile across revisions): apps/server/node_modules/effect/src/ai/McpServer.ts 2139: const mcpTool = new McpTool({ 2140: name: tool.name, 2141: description: Tool.getDescription(tool), 2142: inputSchema, 2143: outputSchema, 2144: annotations: { 2145: ...(Context.getOption(tool.annotations, Tool.Title).pipe( 2146: Option.map((title) => ({ title })), 2147: Option.getOrUndefined 2148: )), 2149: readOnlyHint: Context.get(tool.annotations, Tool.Readonly), 2150: destructiveHint: Context.get(tool.annotations, Tool.Destructive), 2151: idempotentHint: Context.get(tool.annotations, Tool.Idempotent), 2152: openWorldHint: Context.get(tool.annotations, Tool.OpenWorld) 2153: }, 2154: _meta: toolMeta 2155: })