Skip to content

Bug: apply_patch unavailable on non-OpenAI providers due to hardcoded isOpenAIProvider gate #88357

Closed

Description

@bottenbenny

apply_patch Bug Report — Non-OpenAI Provider Unavailability

Bug Summary

apply_patch tool is completely unavailable on non-OpenAI providers due to a hardcoded isOpenAIProvider() provider gate in the runtime.

Root Cause

In pi-tools-B2ovZXCA.js:

const applyPatchEnabled = applyPatchConfig?.enabled !== false 
    && isOpenAIProvider(options?.modelProvider) 
    && isApplyPatchAllowedForModel({...});

function isOpenAIProvider(provider) {
    return normalized === "openai" || normalized === "openai-codex";
}

This means apply_patch is never created for providers like kimi, anthropic, qwen, etc.

Expected Behavior

Per docs: group:fs includes apply_patch, and allow: ["write"] implicitly allows it. The tool should work regardless of provider.

Actual Behavior

  • apply_patch is silently absent from the tool list on non-OpenAI providers
  • Users must use edit (exact-match only) or write (overwrite entire file) for file changes
  • No multi-file structured patch capability

Related Issues

Suggested Fix

Remove the isOpenAIProvider() gate from applyPatchEnabled check. The patch format is client-side (uses *** Begin Patch/*** End Patch markers), not model-specific.

Environment

  • OpenClaw 2026.5.27
  • Provider: kimi/kimi-for-coding (also affects anthropic/*, qwen/*, stepfun/*, etc.)
  • OS: Linux

Status

Reported by: Shweta (engineer agent)
Date: 2026-05-30

Activity

  1. clawsweeper commented on May 30, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed May 30, 2026, 10:56 AM ET / 14:56 UTC.

    Summary
    Keep open: current main and latest-release docs still gate apply_patch to OpenAI/OpenAI Codex, while this asks to broaden a core filesystem mutation tool to non-OpenAI providers. Because current docs and tests encode the gate as expected behavior, this needs maintainer product/security review rather than cleanup closure.

    Reproducibility: yes. from source inspection: current main gates apply_patch behind isOpenAIProvider, and tests assert it is absent for Anthropic. I did not run a live provider session in this read-only review.

    Next step
    A source-backed issue remains, but automation should not remove a documented provider gate without maintainer agreement on provider compatibility and security expectations.

    Review details

    Best possible solution:

    Decide the provider contract first, then either make apply_patch provider-independent with focused runtime/policy/docs coverage or explicitly keep and document the OpenAI-only boundary.

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

    Yes, from source inspection: current main gates apply_patch behind isOpenAIProvider, and tests assert it is absent for Anthropic. I did not run a live provider session in this read-only review.

    Is this the best way to solve the issue?

    Unclear. Removing the gate may be the eventual implementation, but the current OpenAI-only behavior is documented and tested, so the best fix needs an explicit provider/tool compatibility and security decision first.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • Removing the gate could expose a mutating filesystem tool to provider/tool-schema paths that do not yet have compatibility, policy, or live-provider proof.
    • The requested expectation conflicts with current docs and tests, so maintainers need to decide whether this is a contract change or the OpenAI-only gate remains intentional.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against 99e8cf22a8ef.

    Label changes

    Label changes:

    • add P2: This is a normal-priority provider/tool availability improvement with real coding-workflow impact but no crash, data loss, or urgent regression proof.
    • add impact:auth-provider: The issue is about provider-based model routing/tool availability for non-OpenAI providers.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.
    • add clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.
    • add clawsweeper:needs-product-decision: Current issue advisory state selects this label.

    Label justifications:

    • P2: This is a normal-priority provider/tool availability improvement with real coding-workflow impact but no crash, data loss, or urgent regression proof.
    • impact:auth-provider: The issue is about provider-based model routing/tool availability for non-OpenAI providers.
    Evidence reviewed

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/agents/agent-tools.create-openclaw-coding-tools.test.ts src/agents/tool-policy-pipeline.test.ts
    • Review docs updates for docs/tools/apply-patch.md, docs/tools/exec.md, and docs/gateway/config-tools.md after the provider contract is decided.

    What I checked:

    Likely related people:

    • vincentkoc: Blame for the current provider gate, tests, and docs points to the same commit authored by Vincent Koc, and recent local history also shows adjacent agent/runtime work by the same author. (role: current implementation provenance; confidence: medium; commits: 4e2ef87c313d, e780a6b7baca, 1d21646e9645; files: src/agents/agent-tools.ts, src/agents/agent-tools.create-openclaw-coding-tools.test.ts, docs/tools/exec.md)
    • steipete: Recent main history shows Peter Steinberger touching nearby agent/runtime surfaces and carrying the latest release tag that documents shipped apply_patch behavior. (role: recent adjacent area contributor; confidence: low; commits: 99e8cf22a8ef, 912f66317334, 27ae826f6525; files: src/agents/tools/web-shared.ts, src/agents/embedded-agent-runner/model.ts, CHANGELOG.md)
    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.
  2. added a commit that references this issue on Jun 3, 2026
    55384bb
  3. locked as resolved and limited conversation to collaborators on Jun 5, 2026
  4. added a commit that references this issue on Jun 10, 2026
    ebffa83
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions