fix: neutralize codex apply_patch tool description to avoid content-policy block#219
fix: neutralize codex apply_patch tool description to avoid content-policy block#219forrinzhao 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
|
哦,Bro,我明白了,但我希望你可以进行过多测试,进行一个完美的黄金PR 我会感谢你合并这个PR |
|
哎我操 我不在日本国 我无法review这个PR我是糟糕困难的抱歉 等待我20天 |
|
Thanks @forrinzhao 🙏 The diagnosis here is genuinely good. Live-bisecting I'm not merging it as-is though. One hunk has to come out, and the main fix should move somewhere else — details and the exact steps below. 1. Drop the
|
|
Correction to my review above — I got one fact wrong, and it flips the severity, so flagging it before you act on it. I wrote " What that actually changes:
So I had the blast radius backwards: the regression doesn't hit some edge config, it hits the source-install default. That's more reason to drop the hunk, not less. Everything else in the review stands. |
Where this lands — and it lands with your name on itThanks @forrinzhao. I traced this end-to-end (while calibrating a separate billing issue on a paid account) and want to be straight about the outcome. Your finding is real. The root cause is one level deeper than the two string rewrites, though — and it changes the right fix. In the DEVIN_CONNECT branch, So the complete fix is:
Your call how it ships:
Either way you're the author of that rule. No rush for a couple of days; if we don't hear back we'll take route 2 so the fix ships, but I'd genuinely rather merge yours. Small stuff regardless of route:
|
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.Also included (codex bot support)
src/handlers/responses.js: treat bare{role, content}input items (no explicittype:"message", as Codex sends them) as messages so they aren't dropped; route the Responses path through__route: 'messages'(was'responses').Changes
src/handlers/identity-neutralize.js— new exportedsanitizeToolDescriptions()src/handlers/chat.js— apply sanitization to connect toolssrc/handlers/responses.js— codex input-item + routing handlingwindsurfapi-content-policy.patch— standalone clean patch (applies to upstreammaster)