feat(codex): wake threads from background monitoring events - #10183
feat(codex): wake threads from background monitoring events#10183tris203 wants to merge 10 commits into
Conversation
Bugbot is paused — on-demand spend limit reachedBugbot uses usage-based billing for this team and has hit its on-demand spend limit. A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue. |
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR introduces a new Codex background-monitoring workflow across the MCP authorization layer, provider service, event adapter, and session runtime, including automatic wake turns and Stop-time process cleanup. Its cross-cutting runtime and capability/credential changes exceed the scope of an auto-approvable additive change and merit human review. You can add or adjust custom eligibility rules. Learn more. |
…ead-monitoring-state # Conflicts: # apps/server/src/provider/Drivers/CodexDriver.test.ts # apps/server/src/provider/Layers/ProviderInstanceRegistryLive.test.ts
|
Addressed the static-analysis suppression called out in the final approval summary in 7a39b4c: the runtime test now uses the existing Effect FileSystem and Path services, with no diagnostic override. All 13 runtime tests, server typecheck, and targeted lint pass. The monitoring capability remains enabled for Codex as requested; the repository policy requiring human review for product-default changes still applies. |
What Changed
Codex background commands can outlive a turn, but their output does not wake the agent. Add session-scoped
monitor_subscribeandmonitor_unsubscribetools to the existing T3 MCP server so Codex 0.153.2+ can subscribe to a native shell process, finish its turn, and respond when the watcher emits an event.The adapter emits the existing task lifecycle events used by Claude's monitoring UI. Wake output is bounded and coalesced while foreground work runs; Stop cancels background processes and queued wakes. Explicitly rejected events remain recoverable, and ambiguous timeouts retain diagnostics without automatic replay.
Why
Keep process execution under Codex's native shell approvals and sandbox while using T3's existing authenticated MCP toolkit and monitoring presentation. Monitoring capability is independent of browser permission, and tools are hidden from sessions without that capability. No environment marker, monitoring prompt injection, or client UI changes are required.
Validation
Implemented with GPT-6 and GPT-5.6 Sol through the Codex harness in T3 Code.
Note
Add Codex background monitoring with capability-gated MCP subscribe/unsubscribe tools
CodexBackgroundTasksto track native shell tasks, frame their output into bounded monitor events, and queue wake signals for idle threadsMonitorSessionsservice andMonitorSessionregistry so MCP tool calls route subscribe/unsubscribe operations to the matching provider sessionmonitor_subscribeandmonitor_unsubscribeMCP tools, discovered only when the invocation context carries themonitorcapabilityProviderService.prepareMcpSessionnow issuesmonitorcapability for Codex sessions independent of the browserpreviewcapability; sessions with no capabilities receive no credentialCodexSessionRuntimeserializes user turns and monitor wakes, delivers one background wake when the session is idle and subscribed, and onStop/interrupt cancels queued wakes, stops background tasks, and attempts bounded terminal cleanupCodexAdapter.mapToRuntimeEventsexposes background task lifecycle and monitor delivery astask.started,item.completed, andtask.completedruntime eventsCodexSessionRuntime.sendTurnandinterruptTurnnow apply a 10-second timeout to MCP reload and turn-start operations; a stalled Codex peer that previously blocked indefinitely now fails after the timeout.McpCapabilitygained amonitormember andMcpCredentialRequestgained an optionalcapabilitiesfield, defaulting topreviewwhen omitted — out-of-tree callers that construct credential requests withoutcapabilitiesstill get preview-only behavior.Macroscope summarized ce3848a.