Skip to content

fix: neutralize codex apply_patch tool description to avoid content-policy block#218

Closed
forrinzhao wants to merge 4 commits into
dwgx:masterfrom
forrinzhao:content-policy-fix
Closed

fix: neutralize codex apply_patch tool description to avoid content-policy block#218
forrinzhao wants to merge 4 commits into
dwgx:masterfrom
forrinzhao:content-policy-fix

Conversation

@forrinzhao

Copy link
Copy Markdown
Contributor

Problem

When using the Feishu/Lark codex chatbot bridged through the WindsurfAPI proxy, every request failed with:

Your request was blocked by our content policy.

Root cause

The codex apply_patch tool description contains the sentence:

"FREEFORM tool, so do not wrap the patch in JSON."

When this tool description is injected into the system prompt via the tool preamble, Devin Connect's content filter flags it and rejects the whole request. This is a false positive triggered purely by the wording of the tool description, not by any user content.

Fix

Added sanitizeToolDescriptions() in src/handlers/identity-neutralize.js, which rewrites the two flagged fragments:

  • FREEFORMfree-form
  • do not wrap the patch in JSON.provide the patch as plain text.

It is wired into src/handlers/chat.js at connectTools = sanitizeToolDescriptions(_trim.tools).

Can be disabled with env var WINDSURFAPI_NEUTRALIZE_TOOL_DESC=0.

Changes

  • src/handlers/identity-neutralize.js — new exported sanitizeToolDescriptions()
  • src/handlers/chat.js — apply sanitization to connect tools
  • src/handlers/responses.js — related adjustment

A standalone windsurfapi-content-policy.patch is included at the repo root for easy application.

…olicy block

The codex `apply_patch` tool description ("FREEFORM tool, so do not wrap the patch in JSON.") trips Devin Connect content filter when injected via the tool preamble into the system prompt, causing "blocked by our content policy" on Feishu/Lark codex bridge.

sanitizeToolDescriptions() rephrases the two flagged fragments:
  FREEFORM -> free-form
  "do not wrap the patch in JSON." -> "provide the patch as plain text."

Off-switch: WINDSURFAPI_NEUTRALIZE_TOOL_DESC=0
…olicy block

The codex `apply_patch` tool description ("FREEFORM tool, so do not wrap the patch in JSON.") trips Devin Connect content filter when injected via the tool preamble into the system prompt, causing "blocked by our content policy" on Feishu/Lark codex bridge.

sanitizeToolDescriptions() rephrases the two flagged fragments:
  FREEFORM -> free-form
  "do not wrap the patch in JSON." -> "provide the patch as plain text."

Off-switch: WINDSURFAPI_NEUTRALIZE_TOOL_DESC=0
…olicy block

The codex `apply_patch` tool description ("FREEFORM tool, so do not wrap the patch in JSON.") trips Devin Connect content filter when injected via the tool preamble into the system prompt, causing "blocked by our content policy" on Feishu/Lark codex bridge.

sanitizeToolDescriptions() rephrases the two flagged fragments:
  FREEFORM -> free-form
  "do not wrap the patch in JSON." -> "provide the patch as plain text."

Off-switch: WINDSURFAPI_NEUTRALIZE_TOOL_DESC=0
@forrinzhao

Copy link
Copy Markdown
Contributor Author

Closed in favor of #219 — a clean minimal PR based directly on upstream master that contains only the content-policy fix. This draft (#218) accidentally bundled unrelated local branch changes.

@forrinzhao forrinzhao closed this Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant