Skip to content

feat: Freeform apply_patch with simple shell output - #4718

Merged
dylan-hurd-oai merged 6 commits into
mainfrom
dh--text-shell-output-in-flight
Oct 5, 2025
Merged

dylan-hurd-oai merged 6 commits into
mainfrom
dh--text-shell-output-in-flight

Conversation

@dylan-hurd-oai

@dylan-hurd-oai dylan-hurd-oai commented Oct 4, 2025 •

Copy link
Copy Markdown
Contributor

Summary

This PR is an alternative approach to #4711, but instead of changing our storage, parses out shell calls in the client and reserializes them on the fly before we send them out as part of the request.

What this changes:

  1. Adds additional serialization logic when the ApplyPatchToolType::Freeform is in use.
  2. Adds a --custom-apply-patch flag to enable this setting on a session-by-session basis.

This change is delicate, but is not meant to be permanent. It is meant to be the first step in a migration:

  1. (This PR) Add in-flight serialization with config
  2. Update model_family default
  3. Update serialization logic to store turn outputs in a structured format, with logic to serialize based on model_family setting.
  4. Remove this rewrite in-flight logic.

Test Plan

  • Additional unit tests added
  • Tested locally

@dylan-hurd-oai
dylan-hurd-oai requested a review from jif-oai October 4, 2025 09:12
@dylan-hurd-oai dylan-hurd-oai changed the title Dh text shell output in flight feat: --custom-apply-patch with in-flight shell conversion Oct 4, 2025

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

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

Comment thread codex-rs/core/src/client.rs Resolved
@dylan-hurd-oai dylan-hurd-oai changed the title feat: --custom-apply-patch with in-flight shell conversion feat: --custom-apply-patch with in-flight simple shell output Oct 4, 2025
Comment thread codex-rs/tui/src/cli.rs Outdated

/// Force-enable the apply_patch tool even for models that do not opt into it by default.
#[arg(long = "custom-apply-patch", default_value_t = false)]
pub custom_apply_patch: bool,

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.

we have an experimental_supported_tools config, can we reuse it?

@dylan-hurd-oai dylan-hurd-oai Oct 4, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that's only in model_family, not exposed as a config option. I think we should keep this tied to apply_patch_tool_type in ModelFamily, since it's clearer. We do not want to make the Custom definition and the Freeform definition available at the same time.

@pakrym-oai

pakrym-oai commented Oct 4, 2025 •

Copy link
Copy Markdown
Contributor

let's add integration tests that exercise the flag and assert the resulting request body. https://github.com/openai/codex/pull/4706/files for examples

Comment thread codex-rs/core/src/client.rs Resolved

@jif-oai jif-oai 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.

Ok once the config flag is dropped to use the existing one (see Pavel's comment)

@dylan-hurd-oai
dylan-hurd-oai force-pushed the dh--text-shell-output-in-flight branch from 456dee9 to 96bbe5f Compare October 4, 2025 23:28
@dylan-hurd-oai dylan-hurd-oai changed the title feat: --custom-apply-patch with in-flight simple shell output feat: --custom-apply-patch with simple shell output Oct 4, 2025
@dylan-hurd-oai dylan-hurd-oai changed the title feat: --custom-apply-patch with simple shell output feat: Freeform apply_patch with simple shell output Oct 5, 2025
@dylan-hurd-oai
dylan-hurd-oai force-pushed the dh--text-shell-output-in-flight branch from fb7f316 to f4c7577 Compare October 5, 2025 00:31
serde_json::from_str::<Value>(output).is_err(),
"expected truncated shell output to be plain text",
);
assert!(

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.

non-blocking nit: I'd prefer a regex

})
.await?;

loop {

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.

nit: wait_for_event.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copied the pattern from

async fn submit_turn(
- can consolidate into a cleaner helper function in a follow-up?

})
}

fn is_shell_tool_name(name: &str) -> bool {

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.

don't we have to rewrite apply patch?

@dylan-hurd-oai
dylan-hurd-oai merged commit 4764fc1 into main Oct 5, 2025
@dylan-hurd-oai
dylan-hurd-oai deleted the dh--text-shell-output-in-flight branch October 5, 2025 02:16
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 5, 2025
Comment thread codex-rs/exec/src/lib.rs
base_instructions: None,
include_plan_tool: Some(include_plan_tool),
include_apply_patch_tool: Some(true),
include_apply_patch_tool: None,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pakrym-oai @jif-oai this should be off by default - tui has it off and we should only be enabling it for models that support the freeform tool. Many models do not support custom tool calls

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