agents: strengthen GPT-5.4 execution bias and close the one-action-then-narrative loophole#65257
agents: strengthen GPT-5.4 execution bias and close the one-action-then-narrative loophole#65257100yenadmin wants to merge 10 commits intoopenclaw:mainfrom
Conversation
…ative loophole, add tool-first reinforcement
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9490e00d38
ℹ️ 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 "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Strengthens GPT-5.x agent “act-first” behavior in OpenClaw by (1) tightening the OpenAI prompt overlay to more aggressively reinforce tool execution, and (2) extending the planning-only retry guard to catch “one tool call then planning narration” turns that previously escaped retries.
Changes:
- Updated GPT-5 execution-bias overlay text to explicitly require tool/action-first and continued multi-step tool use until completion or a real blocker.
- Added a new heuristic (
isSingleActionThenNarrativePattern) so a single non-plan tool call followed by planning prose can still be treated as “planning-only” for retry purposes. - Added an OpenAI GPT-5
tool_call_stylesection override to reinforce direct tool calling without interleaved narration.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/agents/pi-embedded-runner/run/incomplete-turn.ts | Adds detection to close the “single tool call then plan/permission ask” retry loophole. |
| extensions/openai/prompt-overlay.ts | Strengthens GPT-5 execution bias and introduces a GPT-5 tool-call style override. |
Greptile SummaryThis PR closes the "one action then narrative" loophole in the GPT-5.4 planning-only retry detector and adds a new Two P2 items to consider before merge:
Confidence Score: 5/5Safe to merge; no P0/P1 defects found. Both findings are non-blocking P2 suggestions around test coverage and JSDoc clarity. All changes are logically sound. The loophole fix correctly threads the needle between 0-tool, 1-non-mutating-tool, 1-mutating-tool, and 2+-tool scenarios. Existing tests still pass. Remaining findings are purely test-gap and documentation quality concerns. No files require special attention for correctness; consider adding a test for the 1-non-mutating-tool-call + planning-prose path in run.incomplete-turn.test.ts.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f725a590ac
ℹ️ 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 "@codex address that feedback".
…side-effect guard, JSDoc
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e44b709336
ℹ️ 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 "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a8055323fa
ℹ️ 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 "@codex address that feedback".
…hema help entries
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a64c7af40e
ℹ️ 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 "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 82b60b8b6c
ℹ️ 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 "@codex address that feedback".
… tool_call_style via stablePrefix
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9de4ac9ef6
ℹ️ 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 "@codex address that feedback".
…add single-action unit tests
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3b717b2de
ℹ️ 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 "@codex address that feedback".
|
Maintainer update: We split the narrow GPT-5 prompt / one-action-then-narrative retry slice out of this branch and landed it separately in #65597. Landed commit: Source head from this PR at the time of follow-up triage: The remaining auto-continuation / config-surface work in this PR was intentionally not landed as part of that slice. It is a larger product behavior change and should come back, if desired, as a focused follow-up against current main rather than bundled with the prompt / retry fixes. Closing this PR as superseded by the landed split. |
Summary
Four targeted fixes that close the behavioral gap between GPT-5.4 and Claude agents in OpenClaw. Based on root-cause analysis of the actual code paths in
extensions/openai/prompt-overlay.ts,src/agents/pi-embedded-runner/run.ts, andsrc/agents/pi-embedded-runner/run/incomplete-turn.ts.Part of #64227. See the umbrella for how this fits with #65219 (runtime activation) and #65224 (test proof).
What changed (3 commits)
Commit 1: Prompt + detection layer
extensions/openai/prompt-overlay.tsOPENAI_GPT5_EXECUTION_BIASrewritten from passive ("Start the real work") to imperative ("Use a real tool call FIRST. Commentary-only turns are incomplete. Do not stop after one step to ask permission."). Removed "Before the final answer, quickly verify" which GPT-5.4 used as a pause point.OPENAI_GPT5_TOOL_CALL_STYLEsection override: "Call tools directly without narrating. If multiple tool calls are needed, call them in sequence without stopping." Includes all three approval safety lines from the default section (never exec /approve, allow-once is single-command, preserve full command for approval).resolveOpenAISystemPromptContributionnow returnsexecution_bias+tool_call_style+interaction_styleoverrides.src/agents/pi-embedded-runner/run/incomplete-turn.tsisSingleActionThenNarrativePattern(): detects turns where exactly 1 non-plan tool call + planning prose ("I'll", "let me") = retry eligible.hasNonPlanToolActivity && !isSingleActionThenNarrativePatternso the one-action loophole is closed.Commit 2: Auto-continuation loop
Config surface (
src/config/types.agent-defaults.ts+ zod schemas + labels):agents.defaults.embeddedPi.continuationMode:"auto"/"prompt"/"off"(default:"auto"for strict-agentic GPT-5,"prompt"for everything else)agents.defaults.embeddedPi.continuationBudget: 1-20 (default: 5)Continuation intent detection (
incomplete-turn.ts):hasContinuationIntent()— detects promise patterns in the model's visible texthasCompletionLanguage()— detects "done", "finished", "implemented"AUTO_CONTINUATION_INSTRUCTION— "Continue. Take the next concrete action immediately."The loop (
run.ts, ~line 1720):When GPT-5.4's turn ends with tool results + continuation intent + no completion language, the runner injects the continuation instruction and
continues back to the while loop instead of returning. 11-condition safety guard includes budget, abort, timeout, tool errors, messaging, side effects, approval prompts, and completion language.Commit 3: Review fixes
hasNonPlanToolActivityANDstartedCount > planOnlyToolMetaCountguards now have theisSingleActionThenNarrativePatternexception (Codex-connector P1 finding: the started-count guard was neutralizing the fix).OPENAI_GPT5_TOOL_CALL_STYLEnow includes the three approval safety lines from the default section (Copilot finding: the override was dropping safety guidance).!attempt.replayMetadata.hadPotentialSideEffects(Codex-connector P1 finding: mutating work could be duplicated on retry).isSingleActionThenNarrativePattern.Safety rails on auto-continuation
autoContinuationCount < continuationBudget!aborted && !timedOut!attempt.clientToolCall!attempt.yieldDetected!attempt.lastToolError!attempt.didSendViaMessagingTool!attempt.didSendDeterministicApprovalPrompt!attempt.replayMetadata.hadPotentialSideEffectstoolMetas.some(e => e.toolName !== "update_plan")hasContinuationIntent(...)!hasCompletionLanguage(...)Tests
src/agents/pi-embedded-runner/run.incomplete-turn.test.ts— 16 passedsrc/agents/system-prompt.test.ts— 52 passedClaude is unaffected: continuation loop defaults to
"prompt"for non-strict-agentic runs; prompt overlay only applies to GPT-5 on openai/openai-codex providers.Projected scorecard
How this PR relates to the others