openclaw - ✅(Solved) Fix Question: should openai-codex-responses be in shouldRepairMalformedToolCallArguments? [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#75154Fetched 2026-05-01 05:37:35
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
2
Timeline (top)
commented ×1cross-referenced ×1mentioned ×1subscribed ×1

I'm running GPT-5.5 via the openai-codex provider (ChatGPT Plus OAuth, openai-codex-responses API) on 2026.4.27 and tracing what tool-call self-repair is active for that path. The current gate excludes my transport:

// src/agents/pi-embedded-runner/run/attempt.tool-call-argument-repair.ts:297-306
export function shouldRepairMalformedToolCallArguments(params: {
  provider?: string;
  modelApi?: string | null;
}): boolean {
  return (
    (normalizeProviderId(params.provider ?? "") === "kimi" &&
      params.modelApi === "anthropic-messages") ||
    params.modelApi === "openai-completions"
  );
}

#70294 broadened this from "Kimi-only on anthropic-messages" to also cover openai-completions, with the explicit scope boundary "this does not... broaden the helper to every transport". Commit 2ba43f5d27 fix(agents): keep tool-call repair scoped by transport reinforced the conservative stance.

The openai-responses exclusion is locked in by an explicit test:

// src/agents/pi-embedded-runner/run/attempt.tool-call-argument-repair.test.ts:69-85
it("does not enable the repair for unrelated non-kimi transports", () => {
  expect(
    shouldRepairMalformedToolCallArguments({
      provider: "openai-compatible",
      modelApi: "openai-responses",
    }),
  ).toBe(false);
});
it("keeps kimi providers off on non-anthropic non-openai-completions transports", () => {
  expect(
    shouldRepairMalformedToolCallArguments({
      provider: "kimi-coding",
      modelApi: "openai-responses",
    }),
  ).toBe(false);
});

openai-codex-responses is in the same place as openai-responses — both false. So a Plus-OAuth GPT-5.5 / Codex Mini setup runs without the repair wrapper.

Root Cause

I'm running GPT-5.5 via the openai-codex provider (ChatGPT Plus OAuth, openai-codex-responses API) on 2026.4.27 and tracing what tool-call self-repair is active for that path. The current gate excludes my transport:

// src/agents/pi-embedded-runner/run/attempt.tool-call-argument-repair.ts:297-306
export function shouldRepairMalformedToolCallArguments(params: {
  provider?: string;
  modelApi?: string | null;
}): boolean {
  return (
    (normalizeProviderId(params.provider ?? "") === "kimi" &&
      params.modelApi === "anthropic-messages") ||
    params.modelApi === "openai-completions"
  );
}

#70294 broadened this from "Kimi-only on anthropic-messages" to also cover openai-completions, with the explicit scope boundary "this does not... broaden the helper to every transport". Commit 2ba43f5d27 fix(agents): keep tool-call repair scoped by transport reinforced the conservative stance.

The openai-responses exclusion is locked in by an explicit test:

// src/agents/pi-embedded-runner/run/attempt.tool-call-argument-repair.test.ts:69-85
it("does not enable the repair for unrelated non-kimi transports", () => {
  expect(
    shouldRepairMalformedToolCallArguments({
      provider: "openai-compatible",
      modelApi: "openai-responses",
    }),
  ).toBe(false);
});
it("keeps kimi providers off on non-anthropic non-openai-completions transports", () => {
  expect(
    shouldRepairMalformedToolCallArguments({
      provider: "kimi-coding",
      modelApi: "openai-responses",
    }),
  ).toBe(false);
});

openai-codex-responses is in the same place as openai-responses — both false. So a Plus-OAuth GPT-5.5 / Codex Mini setup runs without the repair wrapper.

Fix Action

Fixed

PR fix notes

PR #75281: fix(agents): repair malformed tool-call args on Codex/Responses transports

Description (problem / solution / changelog)

Summary This PR broadens the malformed tool-call argument repair gate in shouldRepairMalformedToolCallArguments to include specific OpenAI Responses API transports: openai-codex-responses (ChatGPT Plus OAuth) and azure-openai-responses.

Context GPT-5.5 (via Codex) and Azure-hosted models using the Responses API emit toolcall_delta events with the same partial-JSON shape as the openai-completions API. Previously, these were excluded from the repair gate, which could lead to tools receiving empty {} objects or fragmented JSON, causing validation failures.

Refined Changes (Addressing Review Feedback) Narnowed Scope: Following the initial review, I have explicitly excluded the generic openai-responses transport. This is a safety measure because direct OpenAI sessions can route through WebSockets, which build final assistant messages differently and do not emit the toolcall_delta events this specific repair wrapper relies on.

Logic Update: Supported openai-codex-responses and azure-openai-responses in src/agents/pi-embedded-runner/run/attempt.tool-call-argument-repair.ts.

Test Suite Alignment:

Added positive test cases for the enabled SSE/HTTP transports.

Added a negative test case to ensure openai-responses (WebSocket-capable) remains disabled to prevent logic gaps.

Changelog: Updated CHANGELOG.md under the Fixed section with proper contributor credit as required by project policy.

Testing Verification Ran the targeted test suite: pnpm vitest src/agents/pi-embedded-runner/run/attempt.tool-call-argument-repair.test.ts.

Result: 8 tests passed.

Verified that azure-openai-responses and openai-codex-responses return true, while openai-responses and other unrelated transports correctly return false.

Issues Closes #75154

Changed files

  • CHANGELOG.md (modified, +1/-1)
  • src/agents/pi-embedded-runner/run/attempt.tool-call-argument-repair.test.ts (modified, +41/-15)
  • src/agents/pi-embedded-runner/run/attempt.tool-call-argument-repair.ts (modified, +6/-3)

Code Example

// src/agents/pi-embedded-runner/run/attempt.tool-call-argument-repair.ts:297-306
export function shouldRepairMalformedToolCallArguments(params: {
  provider?: string;
  modelApi?: string | null;
}): boolean {
  return (
    (normalizeProviderId(params.provider ?? "") === "kimi" &&
      params.modelApi === "anthropic-messages") ||
    params.modelApi === "openai-completions"
  );
}

---

// src/agents/pi-embedded-runner/run/attempt.tool-call-argument-repair.test.ts:69-85
it("does not enable the repair for unrelated non-kimi transports", () => {
  expect(
    shouldRepairMalformedToolCallArguments({
      provider: "openai-compatible",
      modelApi: "openai-responses",
    }),
  ).toBe(false);
});
it("keeps kimi providers off on non-anthropic non-openai-completions transports", () => {
  expect(
    shouldRepairMalformedToolCallArguments({
      provider: "kimi-coding",
      modelApi: "openai-responses",
    }),
  ).toBe(false);
});
RAW_BUFFERClick to expand / collapse

Context

I'm running GPT-5.5 via the openai-codex provider (ChatGPT Plus OAuth, openai-codex-responses API) on 2026.4.27 and tracing what tool-call self-repair is active for that path. The current gate excludes my transport:

// src/agents/pi-embedded-runner/run/attempt.tool-call-argument-repair.ts:297-306
export function shouldRepairMalformedToolCallArguments(params: {
  provider?: string;
  modelApi?: string | null;
}): boolean {
  return (
    (normalizeProviderId(params.provider ?? "") === "kimi" &&
      params.modelApi === "anthropic-messages") ||
    params.modelApi === "openai-completions"
  );
}

#70294 broadened this from "Kimi-only on anthropic-messages" to also cover openai-completions, with the explicit scope boundary "this does not... broaden the helper to every transport". Commit 2ba43f5d27 fix(agents): keep tool-call repair scoped by transport reinforced the conservative stance.

The openai-responses exclusion is locked in by an explicit test:

// src/agents/pi-embedded-runner/run/attempt.tool-call-argument-repair.test.ts:69-85
it("does not enable the repair for unrelated non-kimi transports", () => {
  expect(
    shouldRepairMalformedToolCallArguments({
      provider: "openai-compatible",
      modelApi: "openai-responses",
    }),
  ).toBe(false);
});
it("keeps kimi providers off on non-anthropic non-openai-completions transports", () => {
  expect(
    shouldRepairMalformedToolCallArguments({
      provider: "kimi-coding",
      modelApi: "openai-responses",
    }),
  ).toBe(false);
});

openai-codex-responses is in the same place as openai-responses — both false. So a Plus-OAuth GPT-5.5 / Codex Mini setup runs without the repair wrapper.

Question

Is the codex/responses exclusion intentional, or is it just a "we did not yet have evidence for that transport" gap?

Specifically:

  1. Does openai-codex-responses (and openai-responses, and azure-openai-responses) emit toolcall_delta events with the same partial-JSON shape as openai-completions? If yes, the repair wrapper would be a no-op for clean streams and a recovery for malformed ones — same as #70294's argument for openai-completions.
  2. Or is there a known reason — e.g., Responses-API-side schema validation, different streaming encoding, prior regression — for keeping it off?

I have not actually observed malformed args on Codex yet, so I am not opening this as a bug. I am asking before considering a PR analogous to #70294 for the codex path.

What I would propose if the answer is "yes, broaden it"

  • Add openai-codex-responses (and possibly openai-responses / azure-openai-responses) to the gate
  • Update the existing "does not enable the repair for unrelated non-kimi transports" test to reflect the new policy
  • Keep the conservative wording in the PR — "Codex/Responses report the same partial-JSON tool-call deltas" rather than "every transport"

Happy to put up a draft PR if that is the path forward, or to wait for guidance.

Environment

  • OpenClaw: 2026.4.27 (82ca6ec)
  • Node: v22.19.0
  • OS: macOS 26.x (Tahoe beta)
  • Provider: openai-codex (ChatGPT Plus OAuth)
  • Model: openai-codex/gpt-5.5

cc @MonkeyLeeT — the recent gate scoping was your call (PR #70294, commit 2ba43f5d27); want to make sure I am reading the intent correctly before broadening it.

extent analysis

TL;DR

The openai-codex-responses exclusion from the tool-call repair wrapper may be unintentional, and adding it to the gate could be a viable solution if it emits toolcall_delta events with the same partial-JSON shape as openai-completions.

Guidance

  • Investigate whether openai-codex-responses emits toolcall_delta events with the same partial-JSON shape as openai-completions to determine if the repair wrapper would be beneficial.
  • Review the existing test cases, such as "does not enable the repair for unrelated non-kimi transports", to ensure they align with the intended behavior for openai-codex-responses.
  • Consider adding openai-codex-responses to the gate if it meets the necessary conditions, and update the relevant test cases to reflect the new policy.
  • Before making any changes, verify that the openai-codex-responses API does not have any known limitations or differences in schema validation, streaming encoding, or prior regressions that would affect the repair wrapper's functionality.

Example

No code snippet is provided as the issue requires investigation and verification of the openai-codex-responses API behavior before making any changes.

Notes

The solution depends on the specific behavior of the openai-codex-responses API, which is not fully described in the issue. Therefore, a thorough investigation is necessary to determine the best course of action.

Recommendation

Apply a workaround by adding openai-codex-responses to the gate if it meets the necessary conditions, as this would provide a consistent behavior with openai-completions and potentially improve the overall functionality of the tool-call repair wrapper.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING