Skip to content

Activate selected capabilities at sampling boundaries#29946

Open
jif-oai wants to merge 1 commit into
jif/inspect-hooks-before-runtime-preparationfrom
jif/activate-selected-capabilities
Open

Activate selected capabilities at sampling boundaries#29946
jif-oai wants to merge 1 commit into
jif/inspect-hooks-before-runtime-preparationfrom
jif/activate-selected-capabilities

Conversation

@jif-oai

@jif-oai jif-oai commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • seed selected roots as generation-zero inactive runtime state so thread startup never waits for an executor
  • prepare MCP and connector candidates from newly ready roots before each model sample
  • validate required MCP servers, then publish the manager, activation, and extension snapshots atomically
  • keep active and candidate MCP managers isolated during startup, elicitation, auto-deny updates, and rollback
  • rematerialize app-server refreshes from the latest config and selected generation at consumption time

Why

A session can outlive several executor readiness transitions, while each model request still needs one coherent world view. This makes readiness dynamic but publication request-scoped: an executor that is pending does not freeze thread creation, and a root that becomes ready is visible only after its complete MCP and connector view can commit at the next sampling boundary.

@jif-oai jif-oai requested a review from a team as a code owner June 25, 2026 01:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ca277e6f7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +92 to +96
let config = turn_context.config.as_ref();
let mcp_config = self
.services
.mcp_manager
.runtime_config_for_thread(config, &candidate)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve reload config when publishing selected capabilities

When config/mcpServer/reload is queued before the first turn that activates a selected executor (or before any later selected-capability generation advances), the turn path first refreshes MCP from the newly loaded config, then prepare_runtime_snapshot immediately rebuilds and swaps the manager using this stale per-turn turn_context.config. That drops any newly added/removed global MCP servers from the just-applied reload for the sampled request; use the refresh config snapshot (or update the session config before activation) so selected-capability publication does not undo config reloads.

AGENTS.md reference: AGENTS.md:L102-L110

Useful? React with 👍 / 👎.

)
.await;
record_inspected_inputs(&sess, &turn_context, inspected_input).await;
return Err(err);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Surface activation failures instead of completing the turn

When the first selected-capability activation fails here (for example, a selected plugin contributes a required MCP server that times out or exits during validate_required_servers), this returns Err before entering the sampling loop that normally converts CodexErr into an ErrorEvent. Session::on_task_finished treats unexpected task errors as a logged warning with no abort reason, so clients receive TurnComplete and no user-visible failure even though the turn never sampled; emit/send the error in this branch as the later sampling error path does.

Useful? React with 👍 / 👎.

Comment on lines +45 to +46
if !self.committed {
self.cancellation_token.cancel();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Shut down cancelled candidate MCP managers

If a turn is interrupted or the session is shut down while a selected-capability candidate is validating, this drop path only cancels the startup token and clears the pending slot. Candidate servers that have already initialized are no longer observing that token, and AsyncManagedClient::shutdown is the path that actually sends shutdown to ready clients, so those MCP processes can be left running with no remaining manager handle to clean them up.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant