Skip to content

[3/6] Add pushed exec process events#18020

Merged
aibrahim-oai merged 5 commits intomainfrom
dev/remote-mcp-exec-events
Apr 17, 2026
Merged

[3/6] Add pushed exec process events#18020
aibrahim-oai merged 5 commits intomainfrom
dev/remote-mcp-exec-events

Conversation

@aibrahim-oai
Copy link
Copy Markdown
Collaborator

@aibrahim-oai aibrahim-oai commented Apr 15, 2026

Summary

  • Add a pushed ExecProcessEvent stream alongside retained process/read output.
  • Publish local and remote output, exit, close, and failure events.
  • Cover the event stream with shared local/remote exec process tests.

Testing

  • cargo check -p codex-exec-server
  • cargo check -p codex-rmcp-client
  • Not run: cargo test per repo instruction; CI will cover.

Stack

o  #18027 [6/6] Fail exec client operations after disconnect
│
o  #18212 [5/6] Wire executor-backed MCP stdio
│
o  #18087 [4/6] Abstract MCP stdio server launching
│
@  #18020 [3/6] Add pushed exec process events
│
o  #18086 [2/6] Support piped stdin in exec process API
│
o  #18085 [1/6] Add MCP server environment config
│
o  main

Copy link
Copy Markdown
Contributor

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

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: a5c217e55a

ℹ️ 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 thread codex-rs/exec-server/src/client.rs Outdated
Comment thread codex-rs/exec-server/src/client.rs Outdated
@aibrahim-oai aibrahim-oai changed the title [3/6] Add pushed exec process events [3/7] Add pushed exec process events Apr 15, 2026
@aibrahim-oai aibrahim-oai changed the title [3/7] Add pushed exec process events [3/8] Add pushed exec process events Apr 16, 2026
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-stdin branch from cf20755 to 315ecdf Compare April 16, 2026 05:10
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-events branch from a5c217e to 69f6bd3 Compare April 16, 2026 05:10
Copy link
Copy Markdown
Contributor

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

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: 69f6bd31a5

ℹ️ 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 thread codex-rs/exec-server/src/local_process.rs Outdated
Copy link
Copy Markdown
Contributor

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

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: 69f6bd31a5

ℹ️ 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 thread codex-rs/exec-server/src/local_process.rs Outdated
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-events branch from 69f6bd3 to 0681926 Compare April 16, 2026 06:20
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-stdin branch 2 times, most recently from 4942819 to cd30150 Compare April 16, 2026 13:55
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-events branch from 0681926 to 4909acf Compare April 16, 2026 13:55
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-stdin branch from cd30150 to 8978634 Compare April 16, 2026 13:59
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-events branch from 4909acf to e89f9e2 Compare April 16, 2026 13:59
Copy link
Copy Markdown
Contributor

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

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: e89f9e2eee

ℹ️ 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 thread codex-rs/exec-server/src/process.rs Outdated
aibrahim-oai added a commit that referenced this pull request Apr 16, 2026
## Summary
- Add an MCP server environment setting with local as the default.
- Thread the default through config serialization, schema generation,
and existing config fixtures.

## Stack
```text
o  #18027 [8/8] Fail exec client operations after disconnect
│
o  #18025 [7/8] Cover MCP stdio tests with executor placement
│
o  #18089 [6/8] Wire remote MCP stdio through executor
│
o  #18088 [5/8] Add executor process transport for MCP stdio
│
o  #18087 [4/8] Abstract MCP stdio server launching
│
o  #18020 [3/8] Add pushed exec process events
│
o  #18086 [2/8] Support piped stdin in exec process API
│
@  #18085 [1/8] Add MCP server environment config
│
o  main
```

Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-stdin branch from 8978634 to 1c5a436 Compare April 16, 2026 15:56
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-events branch 3 times, most recently from 5d0fa36 to fe13f51 Compare April 16, 2026 16:16
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-stdin branch from 1c5a436 to f99255d Compare April 16, 2026 16:16
Copy link
Copy Markdown
Contributor

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

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: fe13f51991

ℹ️ 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 thread codex-rs/exec-server/src/client.rs Outdated
Comment on lines +653 to +658
session.note_change(params.seq);
session.publish_event(ExecProcessEvent::Output(ProcessOutputChunk {
seq: params.seq,
stream: params.stream,
chunk: params.chunk,
}));
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.

P1 Badge Reorder remote exec events by seq before publishing

handle_server_notification publishes remote Output/Exited events immediately in arrival order. Server notifications are emitted from concurrent stdout/stderr/exit tasks, so lower-seq events can arrive after higher-seq ones. Event-only consumers can then reconstruct output incorrectly or see lifecycle transitions out of order. Buffer/reorder by seq before appending to the event log.

Useful? React with 👍 / 👎.

@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-events branch 2 times, most recently from 7d383a5 to 60d1e5b Compare April 16, 2026 16:29
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-stdin branch from f99255d to d29ecfc Compare April 16, 2026 16:29
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-events branch 2 times, most recently from 725940a to e9b4e30 Compare April 16, 2026 16:43
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-stdin branch from 893c39b to ed6b28c Compare April 16, 2026 16:43
aibrahim-oai and others added 2 commits April 16, 2026 12:44
Add pipe_stdin to process/start so non-tty processes can opt into a writable stdin pipe for process/write.

Co-authored-by: Codex <noreply@openai.com>
Add a retained event stream for exec processes so subscribers can consume output and lifecycle events either live or after the process has already closed.

Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-events branch from e9b4e30 to 53ea2a8 Compare April 16, 2026 16:44
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-stdin branch from ed6b28c to 086ae0a Compare April 16, 2026 16:44
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

💡 Codex Review

let mut processes = self.inner.processes.lock().await;
processes
.drain()
.filter_map(|(_, process)| match process {
ProcessEntry::Starting => None,
ProcessEntry::Running(process) => Some(process),
})

P1 Badge Emit terminal event before draining local sessions

LocalProcess::shutdown drains inner.processes before terminating child sessions. Once removed, stream_output/watch_exit can no longer find the process and skip publishing Exited/Closed (or Failed) events. Event-only callers waiting on subscribe_events() can block indefinitely after shutdown because LocalExecProcess still holds an event sender.

ℹ️ 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".

Base automatically changed from dev/remote-mcp-exec-stdin to main April 16, 2026 17:30
aibrahim-oai added a commit that referenced this pull request Apr 16, 2026
## Summary
- Add an explicit stdin mode to process/start.
- Keep normal non-interactive exec stdin closed while allowing
pipe-backed processes.

## Stack
```text
o  #18027 [8/8] Fail exec client operations after disconnect
│
o  #18025 [7/8] Cover MCP stdio tests with executor placement
│
o  #18089 [6/8] Wire remote MCP stdio through executor
│
o  #18088 [5/8] Add executor process transport for MCP stdio
│
o  #18087 [4/8] Abstract MCP stdio server launching
│
o  #18020 [3/8] Add pushed exec process events
│
@  #18086 [2/8] Support piped stdin in exec process API
│
o  #18085 [1/8] Add MCP server environment config
│
o  main
```

Co-authored-by: Codex <noreply@openai.com>
aibrahim-oai and others added 2 commits April 16, 2026 10:30
Add an empty exec process event receiver for mocks and update the unified exec test mock to implement the new event subscription hook.

Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai changed the title [3/8] Add pushed exec process events [3/6] Add pushed exec process events Apr 16, 2026
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai left a comment

Choose a reason for hiding this comment

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

The fact notifications can arrive out of orders was expected (which is why I love having seq numbers) but we will have to be very careful on the client side

Approving to unblock but please process my comments

Comment thread codex-rs/exec-server/src/client.rs Outdated
Comment thread codex-rs/exec-server/src/process.rs Outdated
.history
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner);
history.push_back(event.clone());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This event history is capped by event count, not retained bytes. So with large chunks we could potentially be unbounded (and above the existing 1MiNB cap)

}
}

pub async fn recv(&mut self) -> Result<ExecProcessEvent, broadcast::error::RecvError> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

OOC what's the plan to support Lagged? I think this function should be documented as it will be pretty important

Ok(())
}

async fn assert_exec_process_pushes_events(use_remote: bool) -> Result<()> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should also test the hard case where output/exited/closed/.. notifications arrive out of seq order

Output(ProcessOutputChunk),
Exited { seq: u64, exit_code: i32 },
Closed { seq: u64 },
Failed(String),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we add a seq number? Would make things cleaner

Buffer pushed process events by sequence number so out-of-order closed notifications do not cause later output or exited notifications to be dropped. Bound replay history by retained bytes as well as event count.

Co-authored-by: Codex <noreply@openai.com>
@aibrahim-oai aibrahim-oai force-pushed the dev/remote-mcp-exec-events branch from 3fbc20c to 869142f Compare April 17, 2026 17:56
@aibrahim-oai
Copy link
Copy Markdown
Collaborator Author

@codex review

@aibrahim-oai aibrahim-oai enabled auto-merge (squash) April 17, 2026 19:03
@aibrahim-oai aibrahim-oai merged commit 9d3a5cf into main Apr 17, 2026
42 of 47 checks passed
@aibrahim-oai aibrahim-oai deleted the dev/remote-mcp-exec-events branch April 17, 2026 19:07
@github-actions github-actions bot locked and limited conversation to collaborators Apr 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants