Skip to content

Commit 4dfe995

Browse files
zhouliaomingzhouliaoming
authored andcommitted
fix: enable DeepSeek DSML filtering for proxy providers via model id detection
DSML filtering was gated on thinkingFormat === "deepseek", which resolves only for native deepseek endpoint (api.deepseek.com) or providers with provider key "deepseek". When DeepSeek models are served through proxy providers like SiliconFlow, the endpoint class falls back to "custom" and the filter is never created. This causes DSML markup to leak into visible text, which triggers Feishu streaming-card re-render events that create a feedback loop — resulting in explosive duplicate messages. Fixes by also enabling the filter when the model id contains "deepseek" as a defense-in-depth measure.
1 parent c4a0ca0 commit 4dfe995

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎src/agents/openai-transport-stream.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,10 +2640,10 @@ async function processOpenAICompletionsStream(
26402640
const MAX_TOOL_CALL_ARGUMENT_BUFFER_BYTES = 256_000;
26412641
const emitReasoning = options?.emitReasoning ?? true;
26422642
const compat = getCompat(model as OpenAIModeModel);
2643-
const deepSeekTextFilter = shouldFilterDeepSeekDsmlText(compat)
2643+
const deepSeekTextFilter = shouldFilterDeepSeekDsmlText(compat, model.id)
26442644
? createDeepSeekTextFilter()
26452645
: null;
2646-
const deepSeekToolCallRecoverer = shouldFilterDeepSeekDsmlText(compat)
2646+
const deepSeekToolCallRecoverer = shouldFilterDeepSeekDsmlText(compat, model.id)
26472647
? createDeepSeekDsmlToolCallRecoverer()
26482648
: null;
26492649
const reasoningTagTextPartitioner = createReasoningTagTextPartitioner();
@@ -3074,8 +3074,11 @@ type CompletionsReasoningDelta =
30743074
text: string;
30753075
};
30763076

3077-
function shouldFilterDeepSeekDsmlText(compat: ReturnType<typeof getCompat>) {
3078-
return compat.thinkingFormat === "deepseek";
3077+
function shouldFilterDeepSeekDsmlText(
3078+
compat: ReturnType<typeof getCompat>,
3079+
modelId?: string,
3080+
) {
3081+
return compat.thinkingFormat === "deepseek" || modelId?.includes("deepseek") === true;
30793082
}
30803083

30813084
type RecoveredDeepSeekDsmlToolCall = {

0 commit comments

Comments
 (0)