Skip to content

Conversation

@enyst
Copy link
Collaborator

@enyst enyst commented Dec 20, 2025

HUMAN: I reviewed the code, and I confirm the agent ran the example and it did create the file with the correct contents.

Summary

This PR introduces a GPT-5 preset that uses ApplyPatchTool for file edits, mirroring the pattern in the Gemini tools PR (#1199). It is an optional preset (get_gpt5_agent / get_gpt5_tools) and does not change global defaults or the standard preset behavior.

Rationale

Changes

  • Add openhands-tools/openhands/tools/preset/gpt5.py
    • register_gpt5_tools(enable_browser=True)
    • get_gpt5_tools(enable_browser=True) -> [Terminal, ApplyPatch, TaskTracker, (+Browser)]
    • get_gpt5_condenser(llm)
    • get_gpt5_agent(llm, cli_mode=False)
  • Export get_gpt5_agent from openhands.tools.preset.init

What this PR does NOT do

  • Does not modify default presets or model-aware default mappings
  • Does not change behavior for any existing model by default

Usage

Python (explicit preset):

from openhands.sdk import LLM
from openhands.tools.preset.gpt5 import get_gpt5_agent

llm = LLM(model="openai/gpt-5.1", api_key="…")
agent = get_gpt5_agent(llm)

Or get tools only:

from openhands.sdk import Tool
from openhands.tools.preset.gpt5 import get_gpt5_tools

tools = get_gpt5_tools()
# pass tools to Agent(...)

Backward compatibility

  • No changes to defaults; existing users remain unaffected
  • Users can opt in to the GPT-5 preset if they want ApplyPatch-based editing

Testing & Quality

  • Reuses existing ApplyPatch tool (tested under tests/tools/apply_patch)
  • Pre-commit (ruff, pyright, pycodestyle, tool registration checks) passes locally

Relationship to other PRs

Co-authored-by: openhands openhands@all-hands.dev

@enyst can click here to continue refining the PR


Agent Server images for this PR

GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python amd64, arm64 nikolaik/python-nodejs:python3.12-nodejs22 Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:6b301b0-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-6b301b0-python \
  ghcr.io/openhands/agent-server:6b301b0-python

All tags pushed for this build

ghcr.io/openhands/agent-server:6b301b0-golang-amd64
ghcr.io/openhands/agent-server:6b301b0-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:6b301b0-golang-arm64
ghcr.io/openhands/agent-server:6b301b0-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:6b301b0-java-amd64
ghcr.io/openhands/agent-server:6b301b0-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:6b301b0-java-arm64
ghcr.io/openhands/agent-server:6b301b0-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:6b301b0-python-amd64
ghcr.io/openhands/agent-server:6b301b0-nikolaik_s_python-nodejs_tag_python3.12-nodejs22-amd64
ghcr.io/openhands/agent-server:6b301b0-python-arm64
ghcr.io/openhands/agent-server:6b301b0-nikolaik_s_python-nodejs_tag_python3.12-nodejs22-arm64
ghcr.io/openhands/agent-server:6b301b0-golang
ghcr.io/openhands/agent-server:6b301b0-java
ghcr.io/openhands/agent-server:6b301b0-python

About Multi-Architecture Support

  • Each variant tag (e.g., 6b301b0-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., 6b301b0-python-amd64) are also available if needed

…ult)

- Introduce preset.gpt5 with register/get tools & get_gpt5_agent
- Mirrors Gemini preset pattern; does not change global defaults

Co-authored-by: openhands <openhands@all-hands.dev>
@enyst enyst changed the title feat(preset): add GPT-5 preset using ApplyPatchTool (opt-in alternative to #1281) Add GPT-5 preset using ApplyPatchTool (opt-in) Dec 20, 2025
- Demonstrates opt-in preset via get_gpt5_agent
- Mirrors Gemini example style

Co-authored-by: openhands <openhands@all-hands.dev>
@enyst enyst marked this pull request as ready for review December 20, 2025 04:41
@enyst
Copy link
Collaborator Author

enyst commented Dec 20, 2025

(Agent)

Summary of new changes and validation

  • Example demonstrating the preset
    • examples/01_standalone_sdk/35_gpt5_apply_patch_preset.py
    • Shows how to opt into get_gpt5_agent and run a simple task in the current workspace.

Running the example

  • Executed: uv run python examples/01_standalone_sdk/35_gpt5_apply_patch_preset.py
  • Env: used OPENAI_API_KEY from environment
  • Model default: openai/gpt-5.1
  • Result: Conversation ran successfully and created/updated GPT5_DEMO.txt in repo root:

OpenHands Software Agent SDK for building powerful AI agents.
Includes tools, server, and workspace for developing and running agents.

Run the example with your OpenAI key: Executed locally; succeeded. Done.

"two short lines describing this repository."
)
conversation.run()
print("All done!")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@OpenHands Both this preset example, and the Gemini example in examples/ , fail test-examples workflow because they don't print, idk, something at the end like other examples. Figure it out and fix it.

Also, make sure that both this file and the gemini example file are named correctly, that is, as you can see in their directory, they all increase numbering in the file names. Commit and push to branch.

Copy link

Choose a reason for hiding this comment

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

I'm on it! enyst can track my progress at all-hands.dev

Copy link

Choose a reason for hiding this comment

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

I've fixed the test-examples workflow failures and corrected the file numbering. Here's a summary of the changes:

Changes Made

✅ Fixed EXAMPLE_COST marker issue

Both examples were failing the test-examples workflow because they didn't print the required EXAMPLE_COST: {cost} marker at the end. The test framework checks for this marker to track costs.

  • 33_gemini_file_tools.py: Added EXAMPLE_COST marker
  • 34_gpt5_apply_patch_preset.py: Added EXAMPLE_COST marker

✅ Corrected file numbering

The examples directory had files numbered 30, 31, 32, then jumped to 35. Fixed to be sequential:

  • Renamed 35_gpt5_apply_patch_preset.py34_gpt5_apply_patch_preset.py
  • Added 33_gemini_file_tools.py (new file)

✅ Added missing gemini tools and preset

The gemini example required the gemini tools module which was missing from this branch. Added from main:

  • openhands-tools/openhands/tools/gemini/ (entire module)
  • openhands-tools/openhands/tools/preset/gemini.py
  • Updated openhands-tools/openhands/tools/preset/__init__.py to export gemini preset functions

Commit pushed to branch

The changes have been committed and pushed to feat/preset-gpt5-apply-patch-from-main.

View full conversation

- Add gemini tools and preset from main branch
- Add 33_gemini_file_tools.py example with EXAMPLE_COST marker
- Rename 35_gpt5_apply_patch_preset.py to 34_gpt5_apply_patch_preset.py
- Add EXAMPLE_COST marker to GPT5 example
- Update preset __init__.py to export gemini preset functions

Co-authored-by: openhands <openhands@all-hands.dev>
@enyst enyst mentioned this pull request Dec 23, 2025
enyst and others added 5 commits December 23, 2025 12:22
Resolve conflict in preset __init__.py by keeping both gemini and gpt5 exports.

Co-authored-by: openhands <openhands@all-hands.dev>
- Add EXAMPLE_COST marker to 30_gemini_file_tools.py (from main)
- Remove duplicate 33_gemini_file_tools.py
- Rename GPT5 example from 34 to 33 (sequential numbering)

Co-authored-by: openhands <openhands@all-hands.dev>
30_tom_agent.py already exists, so rename 30_gemini_file_tools.py to 34.

Co-authored-by: openhands <openhands@all-hands.dev>
- Move GPT-5 apply patch preset example to 04_llm_specific_tools/01_gpt5_apply_patch_preset.py
- Move Gemini file tools example to 04_llm_specific_tools/02_gemini_file_tools.py
- Update usage path in docstring

This organizes LLM-specific tool examples into a dedicated folder as suggested
in PR #1486 review.

Co-authored-by: openhands <openhands@all-hands.dev>
@openhands-ai
Copy link

openhands-ai bot commented Dec 23, 2025

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • [Optional] Docs example

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #1462 at branch `feat/preset-gpt5-apply-patch-from-main`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants