Skip to content

Plan mode: stream proposed plans, emit plan items, and render in TUI#9786

Merged
charley-oai merged 2 commits intomainfrom
add-plan-thread-item
Jan 30, 2026
Merged

Plan mode: stream proposed plans, emit plan items, and render in TUI#9786
charley-oai merged 2 commits intomainfrom
add-plan-thread-item

Conversation

@charley-oai
Copy link
Collaborator

@charley-oai charley-oai commented Jan 23, 2026

Summary

  • Stream proposed plans in Plan Mode using <proposed_plan> tags parsed in core, emitting plan deltas plus a plan ThreadItem, while stripping tags from normal assistant output.
  • Persist plan items and rebuild them on resume so proposed plans show in thread history.
  • Wire plan items/deltas through app-server protocol v2 and render a dedicated proposed-plan view in the TUI, including the “Implement this plan?” prompt only when a plan item is present.

Changes

Core (codex-rs/core)

  • Added a generic, line-based tag parser that buffers each line until it can disprove a tag prefix; implements auto-close on finish() for unterminated tags. codex-rs/core/src/tagged_block_parser.rs
  • Refactored proposed plan parsing to wrap the generic parser. codex-rs/core/src/proposed_plan_parser.rs
  • In plan mode, stream assistant deltas as:
    • Normal textAgentMessageContentDelta
    • Plan textPlanDelta + TurnItem::Plan start/completion
      (codex-rs/core/src/codex.rs)
  • Final plan item content is derived from the completed assistant message (authoritative), not necessarily the concatenated deltas.
  • Strips <proposed_plan> blocks from assistant text in plan mode so tags don’t appear in normal messages. (codex-rs/core/src/stream_events_utils.rs)
  • Persist ItemCompleted events only for plan items for rollout replay. (codex-rs/core/src/rollout/policy.rs)
  • Guard update_plan tool in Plan Mode with a clear error message. (codex-rs/core/src/tools/handlers/plan.rs)
  • Updated Plan Mode prompt to:
    • keep <proposed_plan> out of non-final reasoning/preambles
    • require exact tag formatting
    • allow only one <proposed_plan> block per turn
      (codex-rs/core/templates/collaboration_mode/plan.md)

Protocol / App-server protocol

  • Added TurnItem::Plan and PlanDeltaEvent to core protocol items. (codex-rs/protocol/src/items.rs, codex-rs/protocol/src/protocol.rs)
  • Added v2 ThreadItem::Plan and PlanDeltaNotification with EXPERIMENTAL markers and note that deltas may not match the final plan item. (codex-rs/app-server-protocol/src/protocol/v2.rs)
  • Added plan delta route in app-server protocol common mapping. (codex-rs/app-server-protocol/src/protocol/common.rs)
  • Rebuild plan items from persisted ItemCompleted events on resume. (codex-rs/app-server-protocol/src/protocol/thread_history.rs)

App-server

  • Forward plan deltas to v2 clients and map core plan items to v2 plan items. (codex-rs/app-server/src/bespoke_event_handling.rs, codex-rs/app-server/src/codex_message_processor.rs)
  • Added v2 plan item tests. (codex-rs/app-server/tests/suite/v2/plan_item.rs)

TUI

  • Added a dedicated proposed plan history cell with special background and padding, and moved “• Proposed Plan” outside the highlighted block. (codex-rs/tui/src/history_cell.rs, codex-rs/tui/src/style.rs)
  • Only show “Implement this plan?” when a plan item exists. (codex-rs/tui/src/chatwidget.rs, codex-rs/tui/src/chatwidget/tests.rs)
Screenshot 2026-01-29 at 7 06 24 PM

Docs / Misc

  • Updated protocol docs to mention plan deltas. (codex-rs/docs/protocol_v1.md)
  • Minor plumbing updates in exec/debug clients to tolerate plan deltas. (codex-rs/debug-client/src/reader.rs, codex-rs/exec/...)

Tests

  • Added core integration tests:
    • Plan mode strips plan from agent messages.
    • Missing </proposed_plan> closes at end-of-message.
      (codex-rs/core/tests/suite/items.rs)
  • Added unit tests for generic tag parser (prefix buffering, non-tag lines, auto-close). (codex-rs/core/src/tagged_block_parser.rs)
  • Existing app-server plan item tests in v2. (codex-rs/app-server/tests/suite/v2/plan_item.rs)

Notes / Behavior

  • Plan output no longer appears in standard assistant text in Plan Mode; it streams via PlanDelta and completes as a TurnItem::Plan.
  • The final plan item content is authoritative and may diverge from streamed deltas (documented as experimental).
  • Reasoning summaries are not filtered; prompt instructs the model not to include <proposed_plan> outside the final plan message.

Codex Author

codex fork 019bec2d-b09d-7450-b292-d7bcdddcdbfb

@charley-oai charley-oai marked this pull request as draft January 23, 2026 20:32
@charley-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.

Reviewed commit: 26211f235f

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

@charley-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.

Reviewed commit: 85e524fb32

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

@charley-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.

Reviewed commit: 09f4a52ae4

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

@charley-oai
Copy link
Collaborator Author

@codex review this

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Bravo.

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

@charley-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.

Reviewed commit: f2e6793d9d

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

@charley-oai
Copy link
Collaborator Author

@codex review this

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Keep it up!

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

@charley-oai
Copy link
Collaborator Author

@codex review this

@charley-oai charley-oai marked this pull request as ready for review January 24, 2026 08:10
@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Can't wait for the next one!

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

@charley-oai charley-oai changed the title Plan mode: emit ThreadItem::Plan and suppress agent message items Plan mode: emit ThreadItem::Plan using per-turn mode snapshot Jan 24, 2026
@charley-oai
Copy link
Collaborator Author

@codex review this

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Chef's kiss.

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

@shijie-oai shijie-oai left a comment

Choose a reason for hiding this comment

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

Overall looks good to me. Sorry about the back and forth. We shall let @aibrahim-oai take a look cause I am no expert in rust.

@charley-oai charley-oai marked this pull request as draft January 25, 2026 06:15
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.

Reviewed commit: 44ffa2855f

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

@charley-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.

Reviewed commit: 44ffa2855f

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

@charley-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.

Reviewed commit: 22ce553cc1

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

@charley-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.

Reviewed commit: 3c7ae6de11

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

@charley-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.

Reviewed commit: 7c0f5e347c

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

@charley-oai
Copy link
Collaborator Author

@codex review this

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Can't wait for the next one!

ℹ️ 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 Author

@charley-oai charley-oai left a comment

Choose a reason for hiding this comment

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

Will merge in <1 hour

@charley-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.

Reviewed commit: cb88a3a46d

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

@charley-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.

Reviewed commit: 435e6060bf

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

@charley-oai
Copy link
Collaborator Author

@codex review this

@github-actions
Copy link
Contributor

github-actions bot commented Jan 30, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Another round soon, please!

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

@charley-oai
Copy link
Collaborator Author

@codex review this

@charley-oai charley-oai enabled auto-merge (squash) January 30, 2026 18:50
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.

Reviewed commit: f572f452fe

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

@charley-oai charley-oai merged commit ec4a2d0 into main Jan 30, 2026
32 checks passed
@charley-oai charley-oai deleted the add-plan-thread-item branch January 30, 2026 18:59
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 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.

3 participants