Skip to content

[Bug]: repaired code-mode apply_patch wrappers compile the original malformed body #5046

Description

@Ingwannu

Client or integration

Codex code mode through translated Responses/Chat providers.

Area

Custom tool compatibility.

Summary

#4983 recognizes additional malformed exec/apply_patch representations, including outer Markdown fences and fallback fields, but helper compilation still receives the original wrapper.

resolveCodeModeHelperName decides that the repaired body is an apply_patch call. Its callers then pass the original argumentsText to compileCodeModeHelperInput. The compiler's apply-patch branch unwraps only input and patch; it does not consume the other accepted fallback fields or strip the outer fence. Generated JavaScript can therefore call tools.apply_patch with the JSON wrapper or fenced text instead of the patch.

Expected behaviour

Recognition and compilation must consume one canonical repaired body. A representation accepted as an apply-patch helper must compile exactly that patch text, while ordinary caller-defined exec input remains byte-exact.

Required regressions

  • every accepted fallback field compiles to the same raw patch;
  • fenced and unfenced forms compile identically;
  • a normal code-mode JavaScript body remains unchanged;
  • a caller-defined non-code-mode exec is never reinterpreted; and
  • the compiled nested helper succeeds through the actual bridge, not only a recognizer unit test.

Regression origin

Merged in #4983; current dev still calls compileCodeModeHelperInput(args, helper) with the pre-repair args.

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

    bugSomething isn't workingproxyHTTP proxy, routing, reverse-proxy / management authtoolstool_calls, MCP, web-search / sidecar tools

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions