Skip to content

[Bug] DeepSeek CodeModeOnly: unsupported top-level apply_patch call aborts #1544

Description

@c3right

Client or integration

Codex App

Provider or upstream service

DeepSeek (deepseek/deepseek-v4-flash)

OpenCodex version

2.13.0

Endpoint or capability

Routed Responses / CodeModeOnly tool calls / file editing

Current behaviour

In a fresh Codex App conversation routed through OpenCodex to DeepSeek V4 Flash, the model can emit a top-level apply_patch call even though apply_patch is not present in the top-level tool schema for the request.

That call fails with only:

aborted

In the same conversation, patching works through the intended Code Mode path:

exec -> tools.apply_patch(...) -> {}

The file is created, verified, and deleted successfully.

The exposed top-level tools reported for the request include exec, wait, request_user_input, search, and related tools, but not apply_patch.

Expected behaviour

For routed code_mode_only models, tool guidance and accepted tool calls should match the tool schema actually exposed to the model.

If patching is available only through Code Mode, the model should use:

exec -> tools.apply_patch(...)

OpenCodex should not encourage or restore an undeclared top-level apply_patch call. If such a call is nevertheless received, it should produce an actionable compatibility error rather than a bare aborted result.

Minimal redacted request or reproduction

Client: Codex App
OpenCodex: 2.13.0
Provider/model: DeepSeek / deepseek-v4-flash
Conversation: fresh

1. Direct path
   tool: apply_patch
   result: aborted

2. Code Mode path in the same conversation
   tool: exec
   inner tool: tools.apply_patch
   result: {}
   file created, verified, deleted

3. Tool surface
   top-level apply_patch: absent

The direct failure was reproduced in another fresh DeepSeek conversation.

Actual response or error

apply_patch -> aborted
exec -> tools.apply_patch(...) -> {}

There is no patch syntax or filesystem error on the failed path. The nested Code Mode path works in the same environment.

Upstream documentation

DeepSeek Tool Calls documentation:
https://api-docs.deepseek.com/guides/tool_calls

Possibly related upstream Codex issue:
openai/codex#30648

Relevant OpenCodex Code Mode work:
#1361

Suggested mapping or implementation notes

The working nested path strongly suggests the patch runtime itself is healthy. The likely failure is a mismatch between the routed CodeModeOnly tool contract and a direct apply_patch call being generated or restored somewhere in the request/response path.

Please inspect:

  1. CodeModeOnly instructions/guidance for references to direct apply_patch when that tool is not exposed.
  2. DeepSeek Responses conversion/restoration for legacy or undeclared custom-tool calls.
  3. Whether undeclared top-level patch calls should be rejected with a clear diagnostic or mapped to the supported Code Mode path.

Additional context

Controls:

Checks

  • I searched existing provider and compatibility issues.
  • The request and response were redacted.
  • The expected behaviour is based on the concrete tool contract and the working exec -> tools.apply_patch control.

Activity

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

    providerProvider adapters, OpenAI-compat presets, upstream API quirksprovider-compatibilityProvider compatibility reportstoolstool_calls, MCP, web-search / sidecar tools

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions