Skip to content

fix: exclude gpt-5.4-mini from reasoning_effort in /v1/chat/completions#76326

Closed
chinar-amrutkar wants to merge 4 commits into
openclaw:mainfrom
chinar-amrutkar:fix/76176-gpt-54-mini-reasoning-effort
Closed

fix: exclude gpt-5.4-mini from reasoning_effort in /v1/chat/completions#76326
chinar-amrutkar wants to merge 4 commits into
openclaw:mainfrom
chinar-amrutkar:fix/76176-gpt-54-mini-reasoning-effort

Conversation

@chinar-amrutkar

Copy link
Copy Markdown
Contributor

Summary

  • Problem: gpt-5.4-mini does not support reasoning_effort in /v1/chat/completions, but OpenClaw was sending it, causing 400 errors
  • Why it matters: Telegram agents hang with no reply when using openai/gpt-5.4-mini
  • What changed: Added guard for gpt-5.4-mini in resolveOpenAISupportedReasoningEfforts to return [], placed before the broader gpt-5.1 and gpt-5 patterns
  • What did NOT change: Other GPT-5 models retain their reasoning_effort support

Change Type

  • Bug fix

Scope

  • API / contracts

Linked Issue/PR

Root Cause

  • Root cause: gpt-5.4-mini matches /^gpt-5(?:-|$)/u and gets assigned GPT_5_REASONING_EFFORTS, but the model only supports reasoning_effort in the Responses API, not /v1/chat/completions
  • Missing detection / guardrail: No model-specific check excluded gpt-5.4-mini from chat completions reasoning effort

User-visible / Behavior Changes

  • gpt-5.4-mini now works correctly in Telegram agents instead of hanging

Security Impact

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels May 3, 2026
Distinct WhatsApp contacts were colliding on the same :main session key,
causing shared .jsonl files and interleaved model context.

- Added dmScopeOverride to ResolveAgentRouteInput so callers can force a
  specific dmScope regardless of the global config setting
- WhatsApp now passes dmScopeOverride: "per-channel-peer" when resolving
  inbound routes, producing session keys of the form
  agent:{agentId}:whatsapp:direct:{peerId}
- Added regression test verifying distinct peerId values produce distinct
  route.sessionKey values

Closes openclaw#76263
@clawsweeper

clawsweeper Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

Summary
The PR adds an API-scoped gpt-5.4-mini reasoning-effort guard/tests and also changes WhatsApp inbound direct-message routing, last-route handling, docs, tests, and changelog text to force per-contact sessions.

Reproducibility: yes. The linked OpenAI bug is source-reproducible because current main resolves gpt-5.4-mini as reasoning-capable and then emits Chat Completions reasoning_effort; the PR regression is source-reproducible because forcing per-channel-peer removes account IDs from WhatsApp DM session keys.

Next step before merge
A narrow PR-branch repair can preserve WhatsApp account-level dmScope behavior and add the missing OpenAI changelog entry without broader architecture work.

Security
Cleared: The diff only changes TypeScript routing/model compatibility logic, tests, docs, and changelog text; it adds no dependency, workflow, secret, permission, or code-execution surface.

Review findings

  • [P2] Preserve WhatsApp account-level DM isolation — extensions/whatsapp/src/auto-reply/monitor/on-message.ts:97
  • [P3] Add the OpenAI changelog entry — CHANGELOG.md:23
Review details

Best possible solution:

Keep the endpoint-scoped OpenAI fix, preserve documented WhatsApp account-level DM isolation, and either split the unrelated WhatsApp work or cover it with matching tests/docs/changelog before merge.

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

Yes. The linked OpenAI bug is source-reproducible because current main resolves gpt-5.4-mini as reasoning-capable and then emits Chat Completions reasoning_effort; the PR regression is source-reproducible because forcing per-channel-peer removes account IDs from WhatsApp DM session keys.

Is this the best way to solve the issue?

No. The OpenAI API-scoped resolver direction is maintainable, but the branch must not collapse multi-account WhatsApp DMs and still needs the required OpenAI changelog entry.

Full review comments:

  • [P2] Preserve WhatsApp account-level DM isolation — extensions/whatsapp/src/auto-reply/monitor/on-message.ts:97
    The new unconditional override forces every WhatsApp inbound DM to per-channel-peer. buildAgentPeerSessionKey only includes accountId for per-account-channel-peer, and the docs tell multi-account channel users to use that mode, so the same contact messaging two WhatsApp accounts would now share one session. Preserve an explicit per-account scope or force an account-aware scope for WhatsApp.
    Confidence: 0.91
  • [P3] Add the OpenAI changelog entry — CHANGELOG.md:23
    This PR fixes the user-facing gpt-5.4-mini Chat Completions 400 path, but the only changelog addition is for the unrelated WhatsApp session change. Add an Agents/OpenAI or Telegram/OpenAI fix entry for the linked issue before merge.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.91

Acceptance criteria:

  • pnpm test src/agents/openai-reasoning-effort.test.ts extensions/whatsapp/src/auto-reply.web-auto-reply.last-route.test.ts extensions/whatsapp/src/auto-reply/monitor/inbound-dispatch.test.ts src/routing/resolve-route.test.ts
  • pnpm exec oxfmt --check --threads=1 src/agents/openai-reasoning-effort.ts src/agents/openai-reasoning-effort.test.ts extensions/whatsapp/src/auto-reply/monitor/on-message.ts extensions/whatsapp/src/auto-reply/monitor/inbound-dispatch.ts extensions/whatsapp/src/auto-reply/monitor/inbound-dispatch.test.ts extensions/whatsapp/src/auto-reply.web-auto-reply.last-route.test.ts src/routing/resolve-route.ts CHANGELOG.md docs/channels/whatsapp.md
  • pnpm check:changed

What I checked:

Likely related people:

  • steipete: Recent public history lists Peter Steinberger on OpenAI reasoning helper and transport changes, plus recent WhatsApp inbound dispatch maintenance. (role: recent maintainer; confidence: high; commits: 252c63429ecf, 2641b052dc89, 388019f5b693; files: src/agents/openai-reasoning-effort.ts, src/agents/openai-transport-stream.ts, extensions/whatsapp/src/auto-reply/monitor/inbound-dispatch.ts)
  • Shakker: Recent OpenAI manifest/catalog commits touched model capability metadata for the provider surface involved in preserving Responses reasoning. (role: adjacent owner; confidence: medium; commits: 5adbec66e86d, 2b4909e2db28; files: extensions/openai/openclaw.plugin.json)
  • Poo-Squirry: Recent route history credits the binding-level DM scope override work that defines how explicit dmScope should affect direct-message session keys. (role: introduced adjacent behavior; confidence: medium; commits: a1cb8d50ba8d; files: src/routing/resolve-route.ts)
  • Marcus Castro: Recent WhatsApp history includes multi-account inbound state work, which is directly relevant to the account-collapsing risk in this PR's forced per-channel scope. (role: adjacent owner; confidence: medium; commits: 458a52610a4d; files: extensions/whatsapp/src/auto-reply/monitor/on-message.ts, extensions/whatsapp/src/auto-reply/monitor/inbound-dispatch.ts)

Remaining risk / open question:

  • No live Telegram/OpenAI request or PR-branch test run was performed during this read-only review; the verdict relies on source inspection, the linked issue's concrete 400 response, and the public PR diff.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 85e4ec1fb1ac.

@chinar-amrutkar
chinar-amrutkar force-pushed the fix/76176-gpt-54-mini-reasoning-effort branch 2 times, most recently from c8873df to f9e67ae Compare May 3, 2026 00:19
When using per-channel-peer dmScope, updateWhatsAppMainLastRoute now
records the last-route against the per-contact sessionKey instead of
skipping it. This ensures deliveryContext metadata is persisted for
later session deliveries.

Added test: "records last-route for per-contact session when using scoped dmScope"
… guard

The pin guard (pinnedMainDmRecipient) applies only to main session updates.
Per-contact sessions should always record their last-route since they are
independent of the main session pin state.

Updated test to use pinnedMainDmRecipient that differs from dmRouteTarget
to verify the per-contact session is updated even when not the pinned owner.
Only suppress reasoning_effort for gpt-5.4-mini in chat/completions
API. Responses API paths retain GPT_52 reasoning efforts since the
model supports reasoning in that context.

Fixes openclaw#76176
@chinar-amrutkar
chinar-amrutkar force-pushed the fix/76176-gpt-54-mini-reasoning-effort branch from 365780d to 14f6f57 Compare May 3, 2026 09:35
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: whatsapp-web Channel integration: whatsapp-web size: S and removed size: XS labels May 3, 2026
@steipete

steipete commented May 3, 2026

Copy link
Copy Markdown
Contributor

Closing this bundled PR in favor of one PR per issue:

Thanks @chinar-amrutkar for the original fixes; the replacement PRs keep the issues split and preserve the WhatsApp multi-account isolation case.

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

Labels

agents Agent runtime and tooling channel: whatsapp-web Channel integration: whatsapp-web docs Improvements or additions to documentation 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

2 participants