openclaw - ✅(Solved) Fix [Bug]: openai-completions ignores compat.supportsTools=false and still sends tools [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#74664Fetched 2026-04-30 06:21:34
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
2
Timeline (top)
commented ×1cross-referenced ×1

OpenAI-compatible chat-completions models configured with compat.supportsTools: false still receive a tools payload when OpenClaw has tools available.

Error Message

throw new Error('stop after payload capture'); if (event.type === 'error') console.log(event.error.errorMessage);

Root Cause

The process then stops because the repro intentionally throws after capturing onPayload.

Fix Action

Fix / Workaround

Consequence: Chat-only provider runs fail or require local patching/config workarounds even when the model is explicitly marked as not supporting tools.

A local downstream patch fixes this by adding supportsTools to the OpenAI-compatible compat object, merging model.compat.supportsTools, and guarding both context.tools emission and the tool-history tools: [] fallback with compat.supportsTools !== false.

PR fix notes

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

Description (problem / solution / changelog)

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).

Changed files

  • src/agents/openai-transport-stream.test.ts (modified, +87/-0)
  • src/agents/openai-transport-stream.ts (modified, +15/-12)
  • src/agents/pi-project-settings.test.ts (modified, +11/-0)
  • src/agents/pi-project-settings.ts (modified, +5/-0)

Code Example

TMP=$(mktemp -d)
cd "$TMP"
npm init -y >/dev/null
npm install @mariozechner/pi-ai@0.70.5 >/dev/null
node --input-type=module <<'NODE'
import { streamOpenAICompletions } from '@mariozechner/pi-ai/openai-completions';

const model = {
  api: 'openai-completions',
  provider: 'venice',
  id: 'chat-only-model',
  baseUrl: 'https://example.invalid/v1',
  input: ['text'],
  compat: { supportsTools: false },
};

const context = {
  systemPrompt: 'test',
  messages: [{ role: 'user', content: 'hello' }],
  tools: [
    {
      name: 'noop',
      description: 'noop tool',
      parameters: { type: 'object', properties: {} },
    },
  ],
};

const stream = streamOpenAICompletions(model, context, {
  apiKey: 'x',
  onPayload(params) {
    console.log(JSON.stringify({ hasTools: Object.hasOwn(params, 'tools'), tools: params.tools }, null, 2));
    throw new Error('stop after payload capture');
  },
});

for await (const event of stream) {
  if (event.type === 'error') console.log(event.error.errorMessage);
}
NODE

---

{
  "hasTools": true,
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "noop",
        "description": "noop tool",
        "parameters": {
          "type": "object",
          "properties": {}
        },
        "strict": false
      }
    }
  ]
}

---

$ npm view openclaw@2026.4.27-beta.1 dependencies.@mariozechner/pi-ai
0.70.5

$ npm view @mariozechner/pi-ai@0.70.5 version
0.70.5

# Repro output:
{
  "hasTools": true,
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "noop",
        "description": "noop tool",
        "parameters": {
          "type": "object",
          "properties": {}
        },
        "strict": false
      }
    }
  ]
}
stop after payload capture
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

OpenAI-compatible chat-completions models configured with compat.supportsTools: false still receive a tools payload when OpenClaw has tools available.

Steps to reproduce

  1. Install the OpenClaw beta package [email protected] or its dependency @mariozechner/[email protected].
  2. Configure an OpenAI-compatible chat-completions model with compat.supportsTools: false.
  3. Run a request where OpenClaw has at least one tool in context.tools.
  4. Inspect the outbound chat-completions payload before network send.

Minimal payload-capture repro against @mariozechner/[email protected]:

TMP=$(mktemp -d)
cd "$TMP"
npm init -y >/dev/null
npm install @mariozechner/[email protected] >/dev/null
node --input-type=module <<'NODE'
import { streamOpenAICompletions } from '@mariozechner/pi-ai/openai-completions';

const model = {
  api: 'openai-completions',
  provider: 'venice',
  id: 'chat-only-model',
  baseUrl: 'https://example.invalid/v1',
  input: ['text'],
  compat: { supportsTools: false },
};

const context = {
  systemPrompt: 'test',
  messages: [{ role: 'user', content: 'hello' }],
  tools: [
    {
      name: 'noop',
      description: 'noop tool',
      parameters: { type: 'object', properties: {} },
    },
  ],
};

const stream = streamOpenAICompletions(model, context, {
  apiKey: 'x',
  onPayload(params) {
    console.log(JSON.stringify({ hasTools: Object.hasOwn(params, 'tools'), tools: params.tools }, null, 2));
    throw new Error('stop after payload capture');
  },
});

for await (const event of stream) {
  if (event.type === 'error') console.log(event.error.errorMessage);
}
NODE

Expected behavior

When a model is configured with compat.supportsTools: false, the OpenAI-compatible chat-completions payload should not include tools, and tool-history fallback handling should also avoid injecting tools: [].

Actual behavior

The captured payload includes tools even though the model compat explicitly sets supportsTools: false:

{
  "hasTools": true,
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "noop",
        "description": "noop tool",
        "parameters": {
          "type": "object",
          "properties": {}
        },
        "strict": false
      }
    }
  ]
}

The process then stops because the repro intentionally throws after capturing onPayload.

OpenClaw version

2026.4.27-beta.1

Operating system

Ubuntu 24.04 / Linux

Install method

npm package / npm global beta path; isolated repro installed @mariozechner/[email protected], which [email protected] depends on.

Model

OpenAI-compatible chat-completions model with compat.supportsTools: false.

Provider / routing chain

OpenClaw -> @mariozechner/pi-ai openai-completions provider -> OpenAI-compatible endpoint.

Additional provider/model setup details

Observed while using chat-only OpenAI-compatible providers that reject tool schemas. The repro uses a synthetic provider: 'venice' model object only to capture the generated payload before network send; no provider credentials are required.

Logs, screenshots, and evidence

$ npm view [email protected] dependencies.@mariozechner/pi-ai
0.70.5

$ npm view @mariozechner/[email protected] version
0.70.5

# Repro output:
{
  "hasTools": true,
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "noop",
        "description": "noop tool",
        "parameters": {
          "type": "object",
          "properties": {}
        },
        "strict": false
      }
    }
  ]
}
stop after payload capture

Package inspection also shows that buildParams() gates on context.tools but not on compat.supportsTools, and getCompat() does not merge a supportsTools field from model.compat.

Impact and severity

Affected: users of OpenAI-compatible chat-completions providers/models that do not support tools.

Severity: High for those providers, because any run with available tools can send an unsupported tools field and fail before the model can answer.

Frequency: Always reproduced for the payload path above when context.tools is non-empty.

Consequence: Chat-only provider runs fail or require local patching/config workarounds even when the model is explicitly marked as not supporting tools.

Additional information

A local downstream patch fixes this by adding supportsTools to the OpenAI-compatible compat object, merging model.compat.supportsTools, and guarding both context.tools emission and the tool-history tools: [] fallback with compat.supportsTools !== false.

extent analysis

TL;DR

The issue can be fixed by modifying the buildParams() function to check for compat.supportsTools before including tools in the payload.

Guidance

  • Review the buildParams() function to ensure it correctly handles the compat.supportsTools flag.
  • Verify that the getCompat() function merges the supportsTools field from model.compat into the compatibility object.
  • Update the code to guard against including tools in the payload when compat.supportsTools is false.
  • Test the changes with the provided repro script to ensure the tools field is not included in the payload when compat.supportsTools is false.

Example

const buildParams = (context, compat) => {
  const params = {};
  // ...
  if (compat.supportsTools !== false && context.tools) {
    params.tools = context.tools;
  }
  return params;
};

Notes

The fix requires modifying the buildParams() function to correctly handle the compat.supportsTools flag. The provided repro script can be used to test the changes.

Recommendation

Apply the workaround by modifying the buildParams() function to check for compat.supportsTools before including tools in the payload, as this will prevent the tools field from being sent to chat-only providers that do not support tools.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

When a model is configured with compat.supportsTools: false, the OpenAI-compatible chat-completions payload should not include tools, and tool-history fallback handling should also avoid injecting tools: [].

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: openai-completions ignores compat.supportsTools=false and still sends tools [1 pull requests, 1 comments, 2 participants]