Skip to content

fix: guard openai-completions tool payload with supportsTools compat flag - #74738

Merged
steipete merged 3 commits into
openclaw:mainfrom
yelog:fix/74664-openai-completions-supportsTools-false
May 22, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
yelog:fix/74664-openai-completions-supportsTools-false

Conversation

@yelog

@yelog yelog commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #74664.

  • Guards tool payload emission in buildOpenAICompletionsParams with supportsModelTools(model), so models configured with compat.supportsTools: false no longer receive tools or tool_choice in the outbound chat-completions payload.
  • Also suppresses the tools: [] fallback for tool-call history when the model does not support tools.

Problem

buildOpenAICompletionsParams (src/agents/openai-transport-stream.ts) unconditionally added tools to the payload when context.tools was present, and emitted tools: [] when tool-call history existed. The upstream runner layer already gates on supportsModelTools(), but the transport layer did not re-check, so:

  1. Direct SDK callers (e.g. @mariozechner/pi-ai used standalone) bypassed the upstream guard.
  2. Any code path that passed context.tools without pre-filtering hit the same issue.

This caused chat-only OpenAI-compatible providers (e.g. Venice models with compat.supportsTools: false) to receive unsupported tools payloads, triggering 400 errors.

Fix

Wrapped the existing tool-emission block in buildOpenAICompletionsParams with a supportsModelTools(model) check. This reuses the existing helper at src/agents/model-tool-support.ts which returns false when model.compat?.supportsTools === false, defaulting to true otherwise.

Tests

Added 2 test cases to src/agents/openai-transport-stream.test.ts:

  1. omits tools from completions payload when model compat sets supportsTools to false — verifies tools and tool_choice are absent when context.tools is non-empty but model says supportsTools: false.
  2. omits tool-history tools:[] fallback when model compat sets supportsTools to false — verifies the tools: [] fallback for tool-call history is also suppressed.

All 95 tests pass (including 2 new).

Real behavior proof

Behavior addressed: OpenAI Completions payload builder must not send tool fields for models configured with compat.supportsTools: false.
Real environment tested: local OpenClaw source checkout on branch fix/74664-openai-completions-supportsTools-false, head 75b1903dbd0fb6d2031f1fc04fd8a54e54d87d55.
Exact steps or command run after this patch:

node --import tsx -e '<script imports buildOpenAICompletionsParams, builds a chat-only openai-completions model with compat.supportsTools=false, passes context.tools plus toolChoice="auto", and prints only payload field-presence booleans>'

Evidence after fix:

{
  "branch": "fix/74664-openai-completions-supportsTools-false",
  "head": "75b1903dbd0fb6d2031f1fc04fd8a54e54d87d55",
  "command": "node --import tsx payload builder",
  "model": "chat-only-model",
  "compatSupportsTools": false,
  "hasTools": false,
  "hasToolChoice": false,
  "hasParallelToolCalls": false,
  "payloadKeys": [
    "max_completion_tokens",
    "messages",
    "model",
    "stream"
  ]
}

Observed result after fix: The generated OpenAI Completions payload has no tools, no tool_choice, and no parallel_tool_calls even though caller-supplied context.tools and toolChoice were present.
What was not tested: No live external Venice/OpenAI-compatible HTTP request was sent; this proof exercises the production transport payload builder locally and avoids printing prompts, credentials, or full payload content.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Apr 30, 2026
@clawsweeper

clawsweeper Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Latest ClawSweeper review: 2026-05-22 08:30 UTC / May 22, 2026, 4:30 AM ET.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Summary
The branch adds a supportsModelTools(model) guard to OpenAI Completions payload construction, adds two regression tests, and adds a changelog line.

Reproducibility: yes. Source inspection of current main shows the exported builder still emits tool fields without checking supportsModelTools(model), and the PR supplies redacted after-fix builder output showing those fields absent for compat.supportsTools: false.

PR rating
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Summary: Focused patch with direct payload proof and regression coverage; ordinary maintainer review and check gating should be enough.

Rank-up moves:

  • Consolidate the duplicate changelog entry during landing.
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Real behavior proof
Sufficient (live_output): The PR body and follow-up comment include redacted live output from the production payload builder showing no tool-related fields for a compat.supportsTools: false OpenAI Completions model.

Risk before merge

  • The branch adds a changelog line although current main already has an entry for the same linked bug, so landing as-is would duplicate release-note coverage.

Maintainer options:

  1. Decide the mitigation before merge
    Land the builder-level guard and regression tests while keeping the dispatch wrapper as defense in depth, then consolidate the duplicate changelog text during landing.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge
No ClawSweeper repair lane is needed; the PR has no blocking findings and mainly needs maintainer review, normal check gating, and landing-time changelog consolidation.

Security
Cleared: The diff only changes agent transport payload construction, focused tests, and changelog text, with no new dependency, workflow, credential, package-resolution, or downloaded-code execution surface.

Review details

Best possible solution:

Land the builder-level guard and regression tests while keeping the dispatch wrapper as defense in depth, then consolidate the duplicate changelog text during landing.

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

Yes. Source inspection of current main shows the exported builder still emits tool fields without checking supportsModelTools(model), and the PR supplies redacted after-fix builder output showing those fields absent for compat.supportsTools: false.

Is this the best way to solve the issue?

Yes. Reusing the existing supportsModelTools(model) helper inside buildOpenAICompletionsParams() is the narrow maintainable fix because it covers direct builder callers without changing default tool-capable behavior.

Label justifications:

  • P2: This is a focused agent transport bug fix for OpenAI-compatible chat-only models configured with compat.supportsTools: false.
  • rating: 🐚 platinum hermit: Current PR rating is 🐚 platinum hermit because proof is 🐚 platinum hermit, patch quality is 🐚 platinum hermit, and Focused patch with direct payload proof and regression coverage; ordinary maintainer review and check gating should be enough.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body and follow-up comment include redacted live output from the production payload builder showing no tool-related fields for a compat.supportsTools: false OpenAI Completions model.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and follow-up comment include redacted live output from the production payload builder showing no tool-related fields for a compat.supportsTools: false OpenAI Completions model.

What I checked:

Likely related people:

  • Dallin Romney: Local blame for the current OpenAI transport tool-emission block, supportsModelTools helper, and completions tools wrapper points to a broad recent current-main commit by this author; confidence is limited because the commit materialized many agent files at once. (role: recent area contributor; confidence: low; commits: c8a35c4645dc; files: src/agents/openai-transport-stream.ts, src/agents/model-tool-support.ts, src/agents/pi-embedded-runner/openai-stream-wrappers.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 0a4b30191df0.

@yelog
yelog force-pushed the fix/74664-openai-completions-supportsTools-false branch from 08ba619 to 75b1903 Compare May 19, 2026 03:28
@yelog

yelog commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto latest origin/main and resolved the OpenAI transport conflicts while preserving the supportsModelTools(model) guard for both tool payload emission and the tool-history tools: [] fallback.

Validation on the rebased branch:

node scripts/run-vitest.mjs src/agents/openai-transport-stream.test.ts
pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/agents/openai-transport-stream.ts src/agents/openai-transport-stream.test.ts

The first formatter attempt was interrupted while pnpm retried optional binary downloads from the configured registry; retrying the same formatter command with a longer timeout passed.

Remaining merge gate: I still need to add redacted real behavior proof showing an OpenAI Completions payload for a compat.supportsTools: false model no longer includes tools/tool_choice.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels May 19, 2026
@yelog

yelog commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

After-fix real behavior proof from the PR branch, redacted to field presence only.

Behavior addressed: OpenAI Completions payload builder must not send tool fields for models configured with compat.supportsTools: false.
Real environment tested: local OpenClaw source checkout on branch fix/74664-openai-completions-supportsTools-false, head 75b1903dbd0fb6d2031f1fc04fd8a54e54d87d55.
Exact steps or command run after this patch:

node --import tsx -e '<script imports buildOpenAICompletionsParams, builds a chat-only openai-completions model with compat.supportsTools=false, passes context.tools plus toolChoice="auto", and prints only payload field-presence booleans>'

Evidence after fix:

{
  "branch": "fix/74664-openai-completions-supportsTools-false",
  "head": "75b1903dbd0fb6d2031f1fc04fd8a54e54d87d55",
  "command": "node --import tsx payload builder",
  "model": "chat-only-model",
  "compatSupportsTools": false,
  "hasTools": false,
  "hasToolChoice": false,
  "hasParallelToolCalls": false,
  "payloadKeys": [
    "max_completion_tokens",
    "messages",
    "model",
    "stream"
  ]
}

Observed result after fix: The generated OpenAI Completions payload has no tools, no tool_choice, and no parallel_tool_calls even though caller-supplied context.tools and toolChoice were present.
What was not tested: No live external Venice/OpenAI-compatible HTTP request was sent; this proof exercises the production transport payload builder locally and avoids printing prompts, credentials, or full payload content.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 19, 2026
@giodl73-repo giodl73-repo removed the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 21, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 21, 2026
@clawsweeper

clawsweeper Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🥚 common Pearl Merge Sprite

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🥚 common.
Trait: polishes edge cases.
Image traits: location status garden; accessory miniature diff map; palette seafoam, black, and opal; mood focused; pose guarding a tiny green check; shell paper lantern shell; lighting subtle sparkle highlights; background small review tokens.
Share on X: post this hatch
Copy: My PR egg hatched a 🥚 common Pearl Merge Sprite in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@yelog

yelog commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. proof: sufficient ClawSweeper judged the real behavior proof convincing. labels May 22, 2026
@openclaw-barnacle openclaw-barnacle Bot added the proof: supplied External PR includes structured after-fix real behavior proof. label May 22, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 22, 2026
@steipete

Copy link
Copy Markdown
Contributor

Verification before merge: pnpm test src/agents/openai-transport-stream.test.ts (170 passed); autoreview clean. Scope: OpenAI Completions transport gates tool payload/history on existing supportsTools contract.

@steipete
steipete merged commit 76a025c into openclaw:main May 22, 2026
178 of 190 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…flag (openclaw#74738)

* fix: guard openai-completions tool payload with supportsTools compat flag (openclaw#74664)

* docs(changelog): note OpenAI completions tool compat fix

* test(agents): use real tool history fixtures
galiniliev pushed a commit to galiniliev/openclaw that referenced this pull request May 25, 2026
…flag (openclaw#74738)

* fix: guard openai-completions tool payload with supportsTools compat flag (openclaw#74664)

* docs(changelog): note OpenAI completions tool compat fix

* test(agents): use real tool history fixtures
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
…flag (openclaw#74738)

* fix: guard openai-completions tool payload with supportsTools compat flag (openclaw#74664)

* docs(changelog): note OpenAI completions tool compat fix

* test(agents): use real tool history fixtures
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
…flag (openclaw#74738)

* fix: guard openai-completions tool payload with supportsTools compat flag (openclaw#74664)

* docs(changelog): note OpenAI completions tool compat fix

* test(agents): use real tool history fixtures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: openai-completions ignores compat.supportsTools=false and still sends tools

3 participants