fix: neutralize codex apply_patch tool description to avoid content-policy block#218
Closed
forrinzhao wants to merge 4 commits into
Closed
fix: neutralize codex apply_patch tool description to avoid content-policy block#218forrinzhao wants to merge 4 commits into
forrinzhao wants to merge 4 commits into
Conversation
…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
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When using the Feishu/Lark codex chatbot bridged through the WindsurfAPI proxy, every request failed with:
Root cause
The codex
apply_patchtool description contains the sentence: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()insrc/handlers/identity-neutralize.js, which rewrites the two flagged fragments:FREEFORM→free-formdo not wrap the patch in JSON.→provide the patch as plain text.It is wired into
src/handlers/chat.jsatconnectTools = sanitizeToolDescriptions(_trim.tools).Can be disabled with env var
WINDSURFAPI_NEUTRALIZE_TOOL_DESC=0.Changes
src/handlers/identity-neutralize.js— new exportedsanitizeToolDescriptions()src/handlers/chat.js— apply sanitization to connect toolssrc/handlers/responses.js— related adjustmentA standalone
windsurfapi-content-policy.patchis included at the repo root for easy application.