Skip to content

[apply-patch] Clean up apply-patch tool definitions - #2539

Merged
dylan-hurd-oai merged 3 commits into
mainfrom
dh--apply-patch-tool-definition
Aug 22, 2025
Merged

dylan-hurd-oai merged 3 commits into
mainfrom
dh--apply-patch-tool-definition

Conversation

@dylan-hurd-oai

Copy link
Copy Markdown
Contributor

Summary

We've experienced a bit of drift in system prompting for apply_patch:

This PR starts to consolidate our logic in a few ways:

I'm leaving the definition in openai_tools.rs as duplicated text for now because we're going to be iterated on the first-class tool soon.

Testing

  • Added integration tests to verify prompt stability
  • Tested locally with several different models (gpt-5, gpt-oss, o4-mini)

@github-actions

Copy link
Copy Markdown
Contributor

Summary
This PR consolidates and refines apply_patch documentation, adjusts when apply_patch instructions are included in system prompts, exposes/open-renames an OpenAI tool constructor, and adds tests to ensure instruction/tool consistency. Also updates .prettierignore.

Review
Overall direction is solid: clearer docs, better default behavior for instructions, and stronger tests. A couple of correctness/consistency nits to fix before merging:

  • codex-rs/core/tests/prompt_caching.rs: in prompt_tools_are_consistent_across_requests, the second assertion uses body0 instead of body1; change to compare body1["instructions"] to expected_instructions. (Hunk added in this PR; see the block with let body1 = ....)
  • codex-rs/core/src/openai_tools.rs: in the grammar block, “Begin := "_ Begin Patch"” and “End := "_ End Patch"” still use the old markers; update both to *** Begin Patch and *** End Patch to match the rest of the doc. (Hunk around the added grammar section.)
  • codex-rs/core/src/openai_tools.rs: create_tools_json_for_responses_api changed to pub. If external use isn’t intended, keep it pub(crate) and expose only what tests need.
  • codex-rs/core/src/client_common.rs: the new check to include apply_patch instructions when the tool is absent and no override is set looks good; this avoids missing guidance. Consider a brief comment noting this prevents duplication when tools are already present.

If the PR body lacks motivation, suggest: “Unify and centralize apply_patch tool docs, ensure default prompts include apply_patch instructions when needed, and add tests to lock in instruction/tool consistency across requests.”


View workflow run

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

🔥

@ae-openai

Copy link
Copy Markdown
Contributor

Tools

  • apply_patch tool
    • On by default in GPT OSS
    • Can be enabled with -c include_apply_patch_tool=true
  • apply_patch shell command
    • Cleaned up prompt
    • The instructions are now only added if the tool is not present, or for 4o which needs_special_apply_patch_instructions
    • The tool is present either way

@dylan-hurd-oai
dylan-hurd-oai force-pushed the dh--apply-patch-tool-definition branch from 64f5bf2 to 38c1088 Compare August 22, 2025 01:34
@dylan-hurd-oai
dylan-hurd-oai merged commit e4c275d into main Aug 22, 2025
@dylan-hurd-oai
dylan-hurd-oai deleted the dh--apply-patch-tool-definition branch August 22, 2025 03:07
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 22, 2025
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