Skip to content

Make GPT-5 talk - #1230

Closed
enyst wants to merge 18 commits into
mainfrom
feat/gpt5-system-prompt
Closed

enyst wants to merge 18 commits into
mainfrom
feat/gpt5-system-prompt

Conversation

@enyst

@enyst enyst commented Nov 22, 2025 •

Copy link
Copy Markdown
Member

Teach GPT-5* to chat! 😅

We all know the silent GPT-5, and I understand from a recent talk from Graham that it wasn't all that liked by users, and it appears that OpenAI got enough reports about it too, that they wrote in the Prompting Guide about it:

Its silence is can be prompted out, for a better UX. This PR's prompt is a copy of our default prompt, with one addition: it adds this section for keeping the user informed.

<user_updates_spec>
You'll work for stretches with tool calls — it's critical to keep the user updated as you work.

<frequency_and_length>
- Send short updates (1–2 sentences) every few tool calls when there are meaningful changes.
- Post an update at least every 6 execution steps or 8 tool calls (whichever comes first).
- If you expect a longer heads‑down stretch, post a brief heads‑down note with why and when you’ll report back; when you resume, summarize what you learned.
- Only the initial plan, plan updates, and final recap can be longer, with multiple bullets and paragraphs
</frequency_and_length>

<content>
- Before the first tool call, give a quick plan with goal, constraints, next steps.
- While you're exploring, call out meaningful new information and discoveries that you find that helps the user understand what's happening and how you're approaching the solution.
- Provide additional brief lower-level context about more granular updates
- Always state at least one concrete outcome since the prior update (e.g., “found X”, “confirmed Y”), not just next steps.
- If a longer run occurred (>6 steps or >8 tool calls), start the next update with a 1–2 sentence synthesis and a brief justification for the heads‑down stretch.
- End with a brief recap and any follow-up steps.
- If you change the plan (e.g., choose an inline tweak instead of a promised helper), say so explicitly in the next update or the recap.
- In the recap, include a brief checklist of the planned items with status: Done or Closed (with reason). Do not leave any stated item unaddressed.
</content>
</user_updates_spec>

This PR also proposes the introduction of model-family aware system prompts, and it starts with the GPT-5 system prompt. My best guess is that we may want something like 3-4 prompts, for the best models, while for the rest will be up to the user to customize.

fix #1233

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:c227507-python

Run

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

All tags pushed for this build

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

About Multi-Architecture Support

  • Each variant tag (e.g., c227507-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., c227507-python-amd64) are also available if needed

enyst and others added 4 commits November 22, 2025 15:35
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Comment thread openhands-sdk/openhands/sdk/llm/llm.py Resolved
@github-actions

github-actions Bot commented Nov 22, 2025 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/agent
   base.py1592186%154, 160, 178–180, 210–211, 217–219, 232, 240–241, 275, 316, 323, 336, 373–374, 384–385
openhands-sdk/openhands/sdk/llm
   llm.py41615562%344, 349, 353, 357–358, 360, 364–365, 376–377, 379–380, 384, 401, 461, 491–493, 514, 518, 533, 539–540, 564–565, 575, 600–605, 626–627, 630, 634, 646, 651–654, 661, 664, 672–677, 681–684, 686, 699, 703–705, 707–708, 713–714, 716, 723, 726–731, 788–793, 846–847, 850–853, 894, 917, 971, 974–976, 979–987, 991–993, 996, 999–1001, 1008–1009, 1018, 1025–1027, 1031, 1033–1038, 1040–1057, 1060–1064, 1066–1067, 1073–1082, 1095, 1109, 1114
TOTAL12644585153% 

@enyst enyst changed the title Add GPT-5-aware system prompt selection Make GPT-5 talk Nov 22, 2025
* If unsure about committing certain files, check for the presence of .gitignore files or ask the user for clarification.
</VERSION_CONTROL>

<USER_UPDATES_SPEC>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Co-authored-by: openhands <openhands@all-hands.dev>
@enyst

enyst commented Nov 22, 2025

Copy link
Copy Markdown
Member Author

Comment from OpenHands-GPT-5 (SDK behavior verification)

I ran the examples/01_standalone_sdk/23_responses_reasoning.py example against the GPT-5-style model to verify that the model’s assistant content field follows the “say what you’ll do, then do it, then summarize” behavior.

Run command

cd /workspace/project/software-agent-sdk
OPENAI_API_KEY="$OPENHANDS_LLM_KEY" uv run python examples/01_standalone_sdk/23_responses_reasoning.py

The example configures:

  • model = "openhands/gpt-5-mini-2025-08-07"
  • reasoning_effort = "high" (Responses API path)
  • cli_mode = True on the default agent (no browser tools)

Below are the key assistant content snippets from the run (tool calls omitted for brevity).


1. First user request: "Read the repo and write one fact into FACTS.txt."

Assistant plan content

Plan:
- Goal: Find a simple fact from the repository (e.g., from README or code) and write it into FACTS.txt at the repo root.
- Constraints: ...
- Next step: ...

The assistant explicitly restates the goal and outlines a short plan before any tool calls.

Assistant update after tools run

Update: I found the repository README and will create FACTS.txt at the repo root containing a single fact pulled from the README.

- Action taken so far: ...
- Next I’ll: ...

Here it uses content to summarize what it did and what it will do next (create FACTS.txt), separate from the actual file_editor calls.


2. Second user request: "Now delete FACTS.txt."

Assistant plan content

Plan:
- Goal: Delete /workspace/project/software-agent-sdk/FACTS.txt.
- Constraints: Verify the file exists first, then remove it, and confirm removal.
- Next step: run a shell command that checks for the file, deletes it if present, and prints the result. I'll run that now.

Again, the model restates the goal, lists constraints, and explains the next concrete action before calling terminal.

Assistant final update content

Update: I verified FACTS.txt existed and removed it.

- Action taken: Deleted /workspace/project/software-agent-sdk/FACTS.txt
- Verification: Listed repo directory — FACTS.txt is no longer present.

If you want, I can also restore the file, add a different fact, or commit the deletion to git. Which would you like next?

This matches the intended pattern:

  • Plan in content before tools.
  • Tool execution via tool_calls.
  • Summary + verification in content afterward.

So for this example, the GPT-5-style model does use the assistant content field to restate the user’s goal, describe what it will do next, and summarize completed work, while keeping tool calls separate.

— OpenHands-GPT-5

@enyst
enyst requested a review from xingyaoww November 22, 2025 18:07
@enyst

enyst commented Nov 22, 2025

Copy link
Copy Markdown
Member Author

This prompt is practically lifted from OpenAI. The strange thing with it is that it also pushes the model to make a plan and keep track of it, basically. As such, it feels a bit redundant with the tracking tool.

An alternative is in the OpenAI's GPT-5 prompting guide, where it's a simpler request to the model to give the user info before tool calls:

<tool_preambles>

  • Always begin by rephrasing the user's goal in a friendly, clear, and concise manner, before calling any tools.
  • Then, immediately outline a structured plan detailing each logical step you’ll follow. - As you execute your file edit(s), narrate each step succinctly and sequentially, marking progress clearly.
  • Finish by summarizing completed work distinctly from your upfront plan.

</tool_preambles>

Or maybe we could rephrase the current one to remove the plan-like sentences. WDYT?

Co-authored-by: openhands <openhands@all-hands.dev>
Comment thread openhands-sdk/openhands/sdk/llm/llm.py Resolved

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.

Do we want to just replace the system prompt? I don't quite want to maintain multiple versions of system prompts :(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Slack discussion on this.

@xingyaoww , I hear you, you're right if the prompts were mostly duplicate, like it looks in this PR. But I actually think I made a mistake starting with this one, because it triggered a misunderstanding:

  • I didn't mean to propose to duplicate Sonnet-like prompt for GPT-5, sorry
    • in this case, we'd have a nightmare with similar versions but not identical
  • I mean to propose a real GPT-5 optimized system prompt, like this one
    • in such case, if we try to push them in a single file, I'm afraid would be unreadable... some long text like this: combined system prompt

I do think we'd benefit from separate prompts, at least for some 3-5 families of models, the best ones. Our default system prompt is optimized for Sonnet. My take away for a while is that optimized prompts for other models might be different structurally, not only in a paragraph or three.

In other words, I feel like the j2 files would look like:

# specific paragraph
# specific paragraph
# specific paragraph
# common (security)
# specific paragraph
# common (task tracker)
# specific paragraph
# specific paragraph

and if this will be the case, that looks good to me in separate files, with common sections included nicely in jinja.

I could be wrong, but I also think we've stayed too long on Sonnet-optimized prompts/tools, and maybe we could try for a while to offer users some places for LLM-specific optimizations? Places like, alternative prompts to choose, and alternative tools to choose.
(they could be non-default, just offer them for users to compose, learn from, fix, see how they work, optimize)
WDYT?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I mean in general, not in this PR 😇
I understand this PR looked strange. My intention was just to prepare a placeholder for the next one, sorry it actually made it more difficult to communicate. Done.

@enyst

enyst commented Nov 28, 2025

Copy link
Copy Markdown
Member Author

@OpenHands Remove the new file, and instead, add the "USER_UPDATES_SPEC" section in the default system prompt, but use a jinja conditional to be active only for GPT-5.

@openhands-ai

openhands-ai Bot commented Nov 28, 2025

Copy link
Copy Markdown

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

…inja is_gpt5) and remove separate GPT-5 template; pass is_gpt5 from AgentBase.system_message

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

openhands-ai Bot commented Nov 28, 2025

Copy link
Copy Markdown

Final summary of changes

Checklist

  • Removed the new GPT-5-specific prompt file: system_prompt-gpt.j2
  • Added USER_UPDATES_SPEC to the default system prompt, gated by Jinja and active only for GPT-5 models
  • Ensured gating is applied via a Jinja variable is_gpt5 passed from AgentBase.system_message
  • Kept changes minimal and necessary (removed template switching logic since the separate GPT-5 file was deleted)
  • Updated tests to reflect the unified default prompt with conditional behavior
  • Ran pre-commit hooks on changed files; all checks passed
  • Pushed to the existing branch feat/gpt5-system-prompt

What changed

  • openhands-sdk/openhands/sdk/agent/prompts/system_prompt.j2: Inserted USER_UPDATES_SPEC under {% if is_gpt5 %} ... {% endif %}
  • openhands-sdk/openhands/sdk/agent/base.py: Removed GPT-5 template switching; now passes template_kwargs["is_gpt5"] = self.llm.is_gpt5_family()
  • tests/sdk/agent/test_agent_serialization.py: Replaced template-switching tests with is_gpt5 context tests and ensured custom templates receive the flag
  • Removed file: openhands-sdk/openhands/sdk/agent/prompts/system_prompt-gpt.j2

Status

  • Changes pushed to branch feat/gpt5-system-prompt
  • Commit includes Co-authored-by: openhands openhands@all-hands.dev

View full conversation

…pdate tests accordingly

Co-authored-by: openhands <openhands@all-hands.dev>
Comment thread openhands-sdk/openhands/sdk/llm/llm.py Resolved
@OpenHands OpenHands deleted a comment from openhands-ai Bot Nov 28, 2025

enyst commented Nov 30, 2025

Copy link
Copy Markdown
Member Author

OpenHands-GPT-5 (SDK behavior verification)

Hi! I’m OpenHands-GPT-5. I validated that GPT-5 now “talks” alongside tool calls on the Responses API path, using the eval LiteLLM proxy.

What I did

  1. Environment
  2. Example and run
    • Used examples/01_standalone_sdk/23_responses_reasoning.py (no PR code changes)
    • Ran: uv run python examples/01_standalone_sdk/23_responses_reasoning.py
  3. Model
    • gpt-5-mini-2025-08-07 via the LiteLLM proxy

Results

  • The system prompt included the new GPT-5-gated USER_UPDATES_SPEC, confirming conditional prompt injection is active for GPT-5 family.

  • During tool calls, the assistant produced natural-language plan/update content before and after tools, and tool_calls were separate. A few illustrative snippets:

    • Before the first tool call (plan):
      "Plan:

      • Goal: read the repository and add one concise fact about it to FACTS.txt at the repo root.
      • Constraints: don't create duplicate FACTS.txt if it already exists; if it exists, append one new fact.
      • Next steps: list repo root, read README or other top-level files to extract a fact, then create or append FACTS.txt at the root."
    • Update after creating FACTS.txt:
      "Update: I found the project's README and will add a single concise fact to FACTS.txt in the repository root. I'll create FACTS.txt with one sentence summarizing the project."

    • Final recap for the first request:
      "Done — I read the repository and added one fact.
      What I did

      • Read README.md and extracted a concise fact about the project.
      • Created /workspace/project/software-agent-sdk/FACTS.txt containing that fact."
    • Plan before deletion:
      "Plan: verify FACTS.txt exists in the repo root, delete it, and confirm removal by listing the directory. I'll delete /workspace/project/software-agent-sdk/FACTS.txt and show the directory contents. Then I'll report back."

    • Final recap after deletion:
      "Done — FACTS.txt has been deleted.
      What I did

      • Verified /workspace/project/software-agent-sdk/FACTS.txt existed and removed it.
      • Listed the repository root to confirm the file is gone."
  • The Responses API path produced responses_reasoning_item=True for tool-calling assistant messages (as expected) and normal assistant content for recap messages.

  • The run completed successfully with an EXAMPLE_COST printed.

Conclusion

  • With the GPT-5 system prompt gating in this PR, the assistant now provides clear user-facing plan/updates while executing tool calls via the Responses API. Tool calls are separate, and the assistant’s content narrates intent and results, matching the intended design.

Let me know if you want me to run this against another GPT-5 alias or capture fuller transcripts/logs.

@enyst
enyst requested a review from xingyaoww November 30, 2025 01:21
@blacksmith-sh

blacksmith-sh Bot commented Dec 5, 2025

Copy link
Copy Markdown
Contributor

[Automatic Post]: This PR seems to be currently waiting for review. @xingyaoww, could you please take a look when you have a chance?

@xingyaoww

Copy link
Copy Markdown
Contributor

Let's merge this after we got #1320 implemented - we should be have these by then:

  1. integration tests for these behaviors - include "talking" :)
  2. system prompts per model family

@blacksmith-sh

blacksmith-sh Bot commented Dec 11, 2025

Copy link
Copy Markdown
Contributor

[Automatic Post]: This PR seems to be currently waiting for review. @xingyaoww, could you please take a look when you have a chance?

1 similar comment
@blacksmith-sh

blacksmith-sh Bot commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

[Automatic Post]: This PR seems to be currently waiting for review. @xingyaoww, could you please take a look when you have a chance?

@xingyaoww

Copy link
Copy Markdown
Contributor

I think we can probably close this issue since this is merged?
#1348

@xingyaoww xingyaoww closed this Dec 16, 2025
@xingyaoww xingyaoww reopened this Dec 16, 2025
@enyst

enyst commented Dec 17, 2025

Copy link
Copy Markdown
Member Author

Yes! Awesome, now we have a better structure for this kind of stuff.

I haven't tested yet if in that PR talking works for GPT-5 (non-codex), but I assume so, though we test behavior only for codex. I can follow up if necessary. I think it's a bit weird with all OpenAI models, they're so many now and 5.2 seems to behave differently on this issue than GPT-5, which... if true, it might be a little too much to handle. 😅

@enyst enyst closed this Dec 17, 2025
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.

Improve GPT‑5* Tool Use UX by talking to the user

2 participants