Skip to content

feat(openai): support apply_patch built-in tool#37157

Open
Nidhi Rajani (nidhi1603) wants to merge 1 commit into
langchain-ai:masterfrom
nidhi1603:feat/openai-apply-patch-tool
Open

feat(openai): support apply_patch built-in tool#37157
Nidhi Rajani (nidhi1603) wants to merge 1 commit into
langchain-ai:masterfrom
nidhi1603:feat/openai-apply-patch-tool

Conversation

@nidhi1603
Copy link
Copy Markdown

Fixes #37031

Adds support for OpenAI Responses API apply_patch built-in tool.

This PR:

  • Adds apply_patch to the OpenAI well-known tools list.
  • Adds apply_patch to LangChain Core's OpenAI built-in tool passthrough list so bind_tools([{"type": "apply_patch"}]) works.
  • Preserves apply_patch_call and apply_patch_call_output items when converting OpenAI Responses API outputs into LangChain AIMessage.content.
  • Preserves the same item types in streaming AIMessageChunk conversion.
  • Supports round-trip input conversion for apply_patch_call and apply_patch_call_output.
  • Adds unit tests for core tool passthrough, non-streaming conversion, streaming conversion, and round-trip input conversion.

Testing

  • cd libs/core && uv run --group test pytest tests/unit_tests/utils/test_function_calling.py -k "apply_patch" -vv
  • cd libs/partners/openai && uv run --group test pytest tests/unit_tests/chat_models/test_base.py -k "apply_patch" -vv
  • cd libs/core && uv run --all-groups ruff check langchain_core/utils/function_calling.py tests/unit_tests/utils/test_function_calling.py
  • cd libs/partners/openai && uv run --all-groups ruff check langchain_openai/chat_models/base.py tests/unit_tests/chat_models/test_base.py

Read the full contributing guidelines: https://docs.langchain.com/oss/python/contributing/overview

All contributions must be in English. See the language policy.

If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!

Thank you for contributing to LangChain! Follow these steps to have your pull request considered as ready for review.

  1. PR title: Should follow the format: TYPE(SCOPE): DESCRIPTION
  1. PR description:
  • Write 1-2 sentences summarizing the change.
  • The Fixes #xx line at the top is required for external contributions — update the issue number and keep the keyword. This links your PR to the approved issue and auto-closes it on merge.
  • If there are any breaking changes, please clearly describe them.
  • If this PR depends on another PR being merged first, please include "Depends on #PR_NUMBER" in the description.
  1. Run make format, make lint and make test from the root of the package(s) you've modified.
  • We will not consider a PR unless these three are passing in CI.
  1. How did you verify your code works?

Additional guidelines:

  • All external PRs must link to an issue or discussion where a solution has been approved by a maintainer, and you must be assigned to that issue. PRs without prior approval will be closed.
  • PRs should not touch more than one package unless absolutely necessary.
  • Do not update the uv.lock files or add dependencies to pyproject.toml files (even optional ones) unless you have explicit permission to do so by a maintainer.

Social handles (optional)

Twitter: @
LinkedIn: https://linkedin.com/in/

@github-actions github-actions Bot added core `langchain-core` package issues & PRs feature For PRs that implement a new feature; NOT A FEATURE REQUEST integration PR made that is related to a provider partner package integration openai `langchain-openai` package issues & PRs size: M 200-499 LOC labels May 3, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 3, 2026

Merging this PR will not alter performance

✅ 13 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing nidhi1603:feat/openai-apply-patch-tool (3a34a22) with master (8eb3bec)2

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on master (e411a4e) during the generation of this report, so 8eb3bec was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@nidhi1603 Nidhi Rajani (nidhi1603) force-pushed the feat/openai-apply-patch-tool branch from 15ad813 to 3a34a22 Compare May 3, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core `langchain-core` package issues & PRs external feature For PRs that implement a new feature; NOT A FEATURE REQUEST integration PR made that is related to a provider partner package integration new-contributor openai `langchain-openai` package issues & PRs size: M 200-499 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(openai): support for apply_patch built-in tool

1 participant