mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-08-19 03:08:47 +00:00
InputSanitizationMiddleware's text extraction only collected dict blocks with type == "text", so a HumanMessage whose content list carried a bare str item (a shape message_content_to_text treats as text and some IM/SDK clients send) yielded no text at all — the request passed through unwrapped and unescaped, letting forged framework tags (<system-reminder> etc.) reach the model untouched. The sibling rfind-fallback path in _process_request already neutralized bare strings individually, and both ToolResultSanitizationMiddleware and ToolOutputBudgetMiddleware treat bare strings as text; the extraction helper was the odd one out. Collect bare string blocks alongside text-block dicts (skipping empty items, matching message_content_to_text), merging them into the single sanitized text block on rebuild while interleaved non-text blocks keep their positions.