Skip to content

fix: scope gpt-5.4-mini chat reasoning_effort fallback#76727

Merged
steipete merged 2 commits into
mainfrom
fix/76176-gpt54-mini-chat-reasoning
May 3, 2026
Merged

fix: scope gpt-5.4-mini chat reasoning_effort fallback#76727
steipete merged 2 commits into
mainfrom
fix/76176-gpt54-mini-chat-reasoning

Conversation

@steipete

@steipete steipete commented May 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #76176 by handling a narrow OpenAI API incompatibility for gpt-5.4-mini on /v1/chat/completions.

gpt-5.4-mini does support reasoning effort. The failing case is specifically Chat Completions requests that include both function tools and reasoning_effort. OpenAI rejects that combination, which made Telegram-routed fallback runs fail before producing a reply.

Live Verification

Verified against the OpenAI API on 2026-05-03:

Request Result
Chat Completions + function tools, no reasoning_effort HTTP 200
Chat Completions + function tools + reasoning_effort HTTP 400, param=reasoning_effort
Chat Completions + reasoning_effort, no tools HTTP 200
Responses + reasoning.effort HTTP 200

The OpenAI error for the rejected case says function tools with reasoning_effort are not supported for gpt-5.4-mini in /v1/chat/completions and recommends using /v1/responses.

Root Cause

OpenClaw treated model-level reasoning support as sufficient to always emit Chat Completions reasoning_effort. That is correct for tool-free gpt-5.4-mini Chat Completions and for Responses, but not for Chat Completions payloads with function tools.

What Changed

  • Keeps gpt-5.4-mini reasoning-effort support in the model metadata.
  • Keeps reasoning_effort on tool-free gpt-5.4-mini Chat Completions payloads.
  • Keeps reasoning.effort on gpt-5.4-mini Responses payloads.
  • Omits reasoning_effort only when a native OpenAI Chat Completions payload for gpt-5.4-mini includes function tools.
  • Adds regression coverage for both sides of the contract: tool payloads omit the parameter; tool-free payloads keep it.

Scope

OpenAI Chat Completions payload compatibility only. No Telegram transport behavior, model fallback policy, provider routing, auth, credentials, or Responses behavior changes.

Test Plan

  • Live OpenAI API matrix above.
  • pnpm exec oxfmt --write --threads=1 src/agents/openai-reasoning-effort.ts src/agents/openai-reasoning-effort.test.ts src/agents/openai-transport-stream.ts src/agents/openai-transport-stream.test.ts CHANGELOG.md
  • pnpm test src/agents/openai-reasoning-effort.test.ts src/agents/openai-transport-stream.test.ts -- --reporter=verbose
  • GitHub PR CI: green on ea3915308c3c12bb6e71cdb5f13471ec0eb5ba53

Replacement

Replaces the OpenAI-only portion of closed bundled PR #76326.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels May 3, 2026
@clawsweeper

clawsweeper Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR adds gpt-5.4-mini detection, omits Chat Completions reasoning_effort only for tool payloads, and adds focused tests plus a changelog entry.

Reproducibility: yes. source-level reproduction is high confidence: current main can build a gpt-5.4-mini Chat Completions payload with tools and reasoning_effort, matching the OpenAI 400 reported in #76176 and the PR's live matrix.

Next step before merge
No ClawSweeper repair lane is needed; the prior review blocker appears addressed and the PR should proceed through normal maintainer and CI review.

Security
Cleared: The diff only changes TypeScript OpenAI payload compatibility logic, focused tests, and changelog text; it does not touch dependencies, workflows, secrets, or package execution surfaces.

Review details

Best possible solution:

Land the scoped transport-level omission after required CI and maintainer review, keeping reasoning metadata available for Responses and tool-free Chat Completions.

Do we have a high-confidence way to reproduce the issue?

Yes, source-level reproduction is high confidence: current main can build a gpt-5.4-mini Chat Completions payload with tools and reasoning_effort, matching the OpenAI 400 reported in #76176 and the PR's live matrix.

Is this the best way to solve the issue?

Yes, the latest diff is the narrow maintainable fix: suppress only the rejected Chat Completions + function-tools combination while preserving Responses and tool-free Chat reasoning behavior.

What I checked:

Likely related people:

  • steipete: Current-main blame for the OpenAI reasoning resolver, completions payload builder, Responses reasoning path, and transport API registry points to Peter Steinberger's recent agents commit; he also authored the scoped follow-up PR. (role: recent maintainer and likely follow-up owner; confidence: high; commits: 399d7f61783f; files: src/agents/openai-reasoning-effort.ts, src/agents/openai-transport-stream.ts, src/agents/provider-transport-stream.ts)

Remaining risk / open question:

  • This read-only review did not execute the targeted Vitest/format checks; merge should still wait for PR CI or maintainer-run targeted validation.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 935f078a89f0.

@steipete
steipete force-pushed the fix/76176-gpt54-mini-chat-reasoning branch from 2cd1c86 to c1deafa Compare May 3, 2026 14:48

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1deaface2

ℹ️ 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".

Comment thread src/agents/openai-reasoning-effort.ts Outdated
Comment on lines +84 to +89
if (api === "openai-responses" || api === "openai-codex-responses") {
if (/^gpt-5\.4-mini(?:-|$)/u.test(id)) {
return GPT_52_REASONING_EFFORTS;
}
} else if (/^gpt-5\.4-mini(?:-|$)/u.test(id)) {
return [];

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.

P1 Badge Restrict gpt-5.4-mini suppression to chat completions

The new else if branch returns [] for gpt-5.4-mini on every API value except openai-responses/openai-codex-responses, which unintentionally disables reasoning for other Responses surfaces (notably azure-openai-responses used by the Responses transport path) that previously inherited GPT_52_REASONING_EFFORTS. This means Azure/OpenAI Responses requests can now silently lose reasoning effort after this commit; the suppression should be scoped to chat-completions APIs only (for example openai-completions) rather than all non-responses API strings.

Useful? React with 👍 / 👎.

@steipete steipete changed the title fix: omit gpt-5.4-mini chat reasoning_effort fix: scope gpt-5.4-mini chat reasoning_effort fallback May 3, 2026
@steipete
steipete merged commit 11e05e8 into main May 3, 2026
122 of 124 checks passed
@steipete
steipete deleted the fix/76176-gpt54-mini-chat-reasoning branch May 3, 2026 15:02
@steipete

steipete commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

Landed via squash merge onto main.

  • PR head: ea39153
  • Landed commit: 11e05e8
  • Gate: PR CI green on the head SHA; targeted local pnpm test src/agents/openai-reasoning-effort.test.ts src/agents/openai-transport-stream.test.ts -- --reporter=verbose

Thanks @ThisIsAdilah and @chinar-amrutkar.

lxe pushed a commit to lxe/openclaw that referenced this pull request May 6, 2026
Fixes openclaw#76176.

OpenAI live verification showed `gpt-5.4-mini` supports reasoning effort generally, but rejects `/v1/chat/completions` payloads that combine function tools with `reasoning_effort`. This keeps reasoning effort for tool-free Chat Completions and Responses, and omits it only for the rejected Chat Completions + function tools combination.

Validation:
- Live OpenAI API matrix on 2026-05-03
- pnpm test src/agents/openai-reasoning-effort.test.ts src/agents/openai-transport-stream.test.ts -- --reporter=verbose
- GitHub PR CI green on ea39153

Thanks @ThisIsAdilah and @chinar-amrutkar.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
Fixes openclaw#76176.

OpenAI live verification showed `gpt-5.4-mini` supports reasoning effort generally, but rejects `/v1/chat/completions` payloads that combine function tools with `reasoning_effort`. This keeps reasoning effort for tool-free Chat Completions and Responses, and omits it only for the rejected Chat Completions + function tools combination.

Validation:
- Live OpenAI API matrix on 2026-05-03
- pnpm test src/agents/openai-reasoning-effort.test.ts src/agents/openai-transport-stream.test.ts -- --reporter=verbose
- GitHub PR CI green on ea39153

Thanks @ThisIsAdilah and @chinar-amrutkar.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Fixes openclaw#76176.

OpenAI live verification showed `gpt-5.4-mini` supports reasoning effort generally, but rejects `/v1/chat/completions` payloads that combine function tools with `reasoning_effort`. This keeps reasoning effort for tool-free Chat Completions and Responses, and omits it only for the rejected Chat Completions + function tools combination.

Validation:
- Live OpenAI API matrix on 2026-05-03
- pnpm test src/agents/openai-reasoning-effort.test.ts src/agents/openai-transport-stream.test.ts -- --reporter=verbose
- GitHub PR CI green on ea39153

Thanks @ThisIsAdilah and @chinar-amrutkar.
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
Fixes openclaw#76176.

OpenAI live verification showed `gpt-5.4-mini` supports reasoning effort generally, but rejects `/v1/chat/completions` payloads that combine function tools with `reasoning_effort`. This keeps reasoning effort for tool-free Chat Completions and Responses, and omits it only for the rejected Chat Completions + function tools combination.

Validation:
- Live OpenAI API matrix on 2026-05-03
- pnpm test src/agents/openai-reasoning-effort.test.ts src/agents/openai-transport-stream.test.ts -- --reporter=verbose
- GitHub PR CI green on ea39153

Thanks @ThisIsAdilah and @chinar-amrutkar.
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Fixes openclaw#76176.

OpenAI live verification showed `gpt-5.4-mini` supports reasoning effort generally, but rejects `/v1/chat/completions` payloads that combine function tools with `reasoning_effort`. This keeps reasoning effort for tool-free Chat Completions and Responses, and omits it only for the rejected Chat Completions + function tools combination.

Validation:
- Live OpenAI API matrix on 2026-05-03
- pnpm test src/agents/openai-reasoning-effort.test.ts src/agents/openai-transport-stream.test.ts -- --reporter=verbose
- GitHub PR CI green on ea39153

Thanks @ThisIsAdilah and @chinar-amrutkar.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram agent hangs with openai/gpt-5.4-mini; chat-completions fallback sends unsupported reasoning_effort

1 participant