Skip to content

Conversation

@aibrahim-oai
Copy link
Collaborator

@aibrahim-oai aibrahim-oai commented Oct 23, 2025

In this PR, I am exploring migrating task kind to an invocation of Codex. The main reason would be getting rid off multiple ConversationHistory state and streamlining our context/history management.

This approach depends on opening a channel between the sub-codex and codex. This channel is responsible for forwarding interactive (approvals) and non-interactive events. The task is responsible for handling those events.

This opens the door for implementing codex as a tool, replacing compact and review, and potentially subagents.

One consideration is this code is very similar to app-server specially in the approval part. If in the future we wanted an interactive sub-codex we should consider using codex-mcp

@aibrahim-oai aibrahim-oai changed the title Proto on main Oct 23, 2025
@aibrahim-oai
Copy link
Collaborator Author

@review this

Copy link
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.

I like the idea. It would be good to push it slightly further before merging in order to avoid duplicating some logic

Copy link
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.

This is way better IMO

A bunch of tests would be cool

<results>
{results}
</results>
</user_action>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Tab issue

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What does tab issue mean

Copy link
Collaborator

Choose a reason for hiding this comment

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

The indentation of the file is not correct I think

@aibrahim-oai aibrahim-oai marked this pull request as ready for review October 28, 2025 21:18
@chatgpt-codex-connector
Copy link
Contributor

💡 Codex Review

https://github.com/openai/codex/blob/6270245a014cbaf466d2bac8474d6ae82f99e665/codex-rs/core/src/tasks/review.rs#L31-L54
P1 Badge Preserve review output in TaskComplete events

The new delegate-based reviewer always returns None from ReviewTask::run (lines 31‑54), so Session::on_task_finished now emits TaskComplete with last_agent_message: None. Exec/front-end processors such as codex-rs/exec/src/event_processor_with_human_output.rs (lines 173‑182, 515‑516) rely on that field and completely ignore ExitedReviewMode, which means /review executed via the CLI no longer prints any findings at all even though the delegate produced them. The previous implementation propagated the final assistant message through run_task, so TaskComplete carried the review summary. Please return an appropriate string (e.g., the delegate’s overall_explanation) so TaskComplete keeps the review output for clients that only look at that field.

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

@aibrahim-oai
Copy link
Collaborator Author

@codex review this

Copy link
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.

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

@aibrahim-oai
Copy link
Collaborator Author

@codex review this

Copy link
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.

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

Copy link
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.

ℹ️ 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 +50 to +54
};
if !cancellation_token.is_cancelled() {
exit_review_mode(session.clone_session(), output.clone(), ctx.clone()).await;
}
None
Copy link
Contributor

Choose a reason for hiding this comment

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

P1 Badge CLI reviews emit no output after delegate change

The delegate now throws away the reviewer’s final response. In ReviewTask::run (lines 50‑54) the parsed review output is ignored and the task always returns None, so Session::on_task_finished emits TaskComplete { last_agent_message: None }. The only signal that remains is ExitedReviewMode. Clients such as the CLI (codex-rs/exec/src/event_processor_with_human_output.rs lines 156‑205 and 500‑505) render only last_agent_message and currently treat ExitedReviewMode as a no‑op, so invoking /review from the CLI (or other non-TUI frontends) now completes with no review output at all. We need to either return the reviewer’s final text here (as before) or update those clients to consume the structured review event, otherwise reviews outside the TUI are unusable.

Useful? React with 👍 / 👎.

@aibrahim-oai
Copy link
Collaborator Author

@codex review this

Copy link
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

info!("spawning ghost snapshot task");
let task = GhostSnapshotTask::new(token);
Arc::new(task)
.run(
Arc::new(SessionTaskContext::new(self.clone())),

P1 Badge Honor GhostCommit flag before spawning ghost snapshots

Lines 1107‑1111 unconditionally spawn GhostSnapshotTask every time maybe_start_ghost_snapshot runs, and run_task still invokes this helper for every turn (line 1675). The guard that previously short‑circuited when Feature::GhostCommit was disabled or when the turn was a review thread was removed, so ghost snapshots now run even when the feature is turned off in the session config. That causes unexpected repo writes and extra approvals for users who explicitly disabled snapshots. Please restore the feature/review checks so the background task only runs when snapshots are enabled.

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

@aibrahim-oai aibrahim-oai changed the title Prototype to delegate review to codex instance Oct 29, 2025
@aibrahim-oai
Copy link
Collaborator Author

@codex review this

@chatgpt-codex-connector
Copy link
Contributor

💡 Codex Review

let mut prev_agent_message: Option<Event> = None;
while let Ok(event) = receiver.recv().await {
match event.clone().msg {
EventMsg::AgentMessage(_) => {
if let Some(prev) = prev_agent_message.take() {
session
.clone_session()
.send_event(ctx.as_ref(), prev.msg)
.await;

P1 Badge Preserve review output for non‑TUI clients

The new delegate never forwards the reviewer’s final response. In process_review_events the current AgentMessage is stored in prev_agent_message and only sent once another AgentMessage arrives (lines 104‑112), and ReviewTask::run now always returns None, so the parent session emits TaskComplete with no last_agent_message. A review normally emits exactly one AgentMessage, so nothing ever reaches the parent. The CLI/exec processors (codex-rs/exec/src/event_processor_with_human_output.rs lines 183‑220 and 505‑516) only render AgentMessage events or TaskComplete.last_agent_message and explicitly ignore ExitedReviewMode, which means running /review in codex-cli now produces no findings (and --output files stay empty). The final AgentMessage needs to be forwarded—or injected into the TaskComplete payload—so non‑TUI clients still receive the review results.

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

Copy link
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.

Looks pretty good
A few comment left and our async discussion on the source of the SubAgent (to be piped to the client). Then, looks good to me
Ping me if you want another review

@aibrahim-oai aibrahim-oai enabled auto-merge (squash) October 29, 2025 21:04
@aibrahim-oai aibrahim-oai merged commit 13e1d03 into main Oct 29, 2025
62 of 67 checks passed
@aibrahim-oai aibrahim-oai deleted the proto-on-main branch October 29, 2025 21:04
@github-actions github-actions bot locked and limited conversation to collaborators Oct 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

4 participants