Skip to content

fix(agents): suppress DeepSeek DSML stream artifacts - #78331

Merged
steipete merged 2 commits into
openclaw:mainfrom
samzong:fix/deepseek-dsml-stream-leak
May 9, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
samzong:fix/deepseek-dsml-stream-leak

Conversation

@samzong

@samzong samzong commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem: DeepSeek/OpenAI-compatible streaming can surface provider-private DSML spans such as tool_use_error, tool_call, tool_calls, and function_calls inside choice.delta.content, and the core stream path would otherwise append that text to assistant-visible output.
  • Why it matters: raw DSML control syntax can leak into downstream user-facing renderers and transcripts, while treating it as executable tool-call syntax would be unsafe because native delta.tool_calls is the authoritative function-calling contract.
  • What changed: added a DeepSeek-compatible streaming text filter that suppresses closed, split-across-chunk, and unterminated DSML spans before visible text is emitted, while preserving native delta.tool_calls and upstream finish_reason / stopReason behavior.
  • What did NOT change (scope boundary): this PR does not parse DSML into toolCall blocks, does not override stop reasons from DSML text, and does not expand or redesign existing inline-thinking handling.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #
  • Related #
  • This PR fixes a bug or regression

Real behavior proof (required for external PRs)

External contributors must show after-fix evidence from a real OpenClaw setup. Unit tests, mocks, lint, typechecks, snapshots, and CI are supplemental only. Screenshots are encouraged even for CLI, console, text, or log changes; terminal screenshots and copied live output count.

  • Behavior or issue addressed: provider-private DeepSeek DSML transport spans in OpenAI-compatible streaming text should be suppressed from assistant-visible output without converting DSML text into executable tool calls.
  • Real environment tested: local OpenClaw CLI from this branch on macOS, Node 22+/pnpm, using configured DeepSeek API-key auth (deepseek:default, secret redacted).
  • Exact steps or command run after this patch: pnpm openclaw infer model run --local --model deepseek/deepseek-v4-flash --prompt 'Reply exactly: OPENCLAW_DSML_LIVE_PROOF_OK' --json; plus pnpm test src/agents/deepseek-text-filter.test.ts src/agents/openai-transport-stream.test.ts.
  • Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output): copied live CLI output from a real DeepSeek-backed OpenClaw run:
{
  "ok": true,
  "capability": "model.run",
  "transport": "local",
  "provider": "deepseek",
  "model": "deepseek-v4-flash",
  "attempts": [],
  "outputs": [
    {
      "text": "OPENCLAW_DSML_LIVE_PROOF_OK",
      "mediaUrl": null
    }
  ]
}

Targeted replay tests additionally pass through the real processOpenAICompletionsStream parser and assert DSML does not appear in emitted events while native delta.tool_calls still produces a toolCall block.

  • Observed result after fix: the live DeepSeek-backed OpenClaw command returned only the requested assistant text and no DSML control syntax. Targeted parser replay shows closed, split-across-chunk, singular, plural, and unterminated DSML spans are dropped from visible assistant text; native delta.tool_calls remains intact; upstream stopReason remains mapped from finish_reason.
  • What was not tested: a live provider response that naturally emits DSML was not reproduced on demand; DSML-specific suppression remains covered by parser replay against DeepSeek-shaped chunks.
  • Before evidence (optional but encouraged): source-level failure path on main appends non-empty choice.delta.content directly to assistant-visible text, so any DSML content delta leaks unchanged.

Root Cause (if applicable)

For bug fixes or regressions, explain why this happened, not just what changed. Otherwise write N/A. If the cause is unclear, write Unknown.

  • Root cause: OpenAI-compatible streaming treated every non-empty choice.delta.content string as visible assistant text, but DeepSeek-compatible streams can include provider-private DSML transport syntax in that same field.
  • Missing detection / guardrail: there was no DeepSeek-compatible content filter guarding provider-private DSML spans before visible text emission.
  • Contributing context (if known): native delta.tool_calls and provider-private DSML text share the same stream, but only delta.tool_calls is a safe executable tool-call contract.

Regression Test Plan (if applicable)

For bug fixes or regressions, name the smallest reliable test coverage that should catch this. Otherwise write N/A.

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/agents/deepseek-text-filter.test.ts; src/agents/openai-transport-stream.test.ts.
  • Scenario the test should lock in: DSML spans are suppressed across chunk boundaries and at stream end; singular close tokens are accepted; native delta.tool_calls ordering and output are preserved.
  • Why this is the smallest reliable guardrail: the filter tests cover chunk-boundary state-machine behavior, and the transport test covers the actual parser seam without requiring live provider credentials.
  • Existing test that already covers this (if any): none before this PR.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

DeepSeek-compatible provider-private DSML syntax is no longer shown in assistant-visible text. Native tool calls continue to behave as before.

Diagram (if applicable)

Before:
DeepSeek content delta -> raw DSML text -> assistant-visible text

After:
DeepSeek content delta -> DSML suppress-only filter -> assistant-visible text without DSML
                         -> native delta.tool_calls unchanged -> toolCall block

Security Impact (required)

  • New permissions/capabilities? (Yes/No): No
  • Secrets/tokens handling changed? (Yes/No): No
  • New/changed network calls? (Yes/No): No
  • Command/tool execution surface changed? (Yes/No): No
  • Data access scope changed? (Yes/No): No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: macOS local development environment
  • Runtime/container: Node 22+ / pnpm repo test wrapper; pnpm openclaw infer model run --local
  • Model/provider: live deepseek/deepseek-v4-flash via configured DeepSeek auth, plus DeepSeek-compatible OpenAI completions stream shape via targeted replay
  • Integration/channel (if any): core agent OpenAI-compatible stream transport
  • Relevant config (redacted): N/A

Steps

  1. Replay DeepSeek-shaped stream chunks containing DSML content through processOpenAICompletionsStream.
  2. Include a native delta.tool_calls chunk in the same stream.
  3. Run pnpm test src/agents/deepseek-text-filter.test.ts src/agents/openai-transport-stream.test.ts.
  4. Run pnpm openclaw infer model run --local --model deepseek/deepseek-v4-flash --prompt 'Reply exactly: OPENCLAW_DSML_LIVE_PROOF_OK' --json.
  5. Run pnpm check:changed.

Expected

  • DSML spans are absent from assistant-visible text and emitted stream events.
  • Native delta.tool_calls still creates a real toolCall block.
  • Upstream finish_reason / stopReason behavior is preserved.

Actual

  • Targeted tests assert the expected suppress-only behavior and native tool-call preservation; the live OpenClaw/DeepSeek command returns OPENCLAW_DSML_LIVE_PROOF_OK with ok: true, transport: "local", provider: "deepseek", and model: "deepseek-v4-flash".
  • pnpm check:changed touched-surface checks passed; unrelated tsgo failures reproduce on clean upstream/main because of @openclaw/fs-safe API drift in infra files.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: live DeepSeek-backed OpenClaw model run succeeds through the local CLI; DSML suppression for tool_use_error, tool_call, tool_calls, function_calls, split open tokens, singular close tokens, multiple blocks, and unterminated blocks; native delta.tool_calls remains authoritative and visible text ordering is preserved.
  • Edge cases checked: chunk-boundary partial DSML open token, singular/plural DSML close-token variants, stream-end flush of retained text, and native tool call in a stream that also contains DSML content.
  • What you did not verify: a naturally occurring live DSML leak from DeepSeek; the live run verifies the real provider/OpenClaw path, while DSML leak shapes are verified by targeted parser replay.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes/No): Yes
  • Config/env changes? (Yes/No): No
  • Migration needed? (Yes/No): No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

List only real risks for this PR. Add/remove entries as needed. If none, write None.

  • Risk: DSML-looking text that a DeepSeek-compatible model intentionally writes as prose may be suppressed.
    • Mitigation: filtering is limited to the existing DeepSeek-compatible stream contract and only targets known DSML control-span forms; native delta.tool_calls remains the only executable path.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M proof: supplied External PR includes structured after-fix real behavior proof. labels May 6, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f92fdb330

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/openai-transport-stream.ts Resolved
@clawsweeper

clawsweeper Bot commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
The PR adds a DeepSeek-gated DSML text filter to OpenAI-compatible streaming, wires it into processOpenAICompletionsStream, adds parser/filter tests, and updates the changelog.

Reproducibility: yes. at source level: current main appends string choice.delta.content directly to visible assistant text, and the PR's own parser tests show DSML-shaped chunks reaching this seam. I did not establish a fresh live DeepSeek response that naturally emits DSML.

Real behavior proof
Needs stronger real behavior proof before merge: The copied live DeepSeek output proves a normal provider run, but it does not show a DSML-bearing stream after the fix; DSML suppression is only shown by synthetic parser replay. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, ask a maintainer to comment @clawsweeper re-review.

Next step before merge
Human follow-up is needed because this external draft PR has blocking stream-filter findings and insufficient DSML-exercising real behavior proof; automation should not repair the branch before contributor proof is supplied.

Security
Cleared: Cleared: the diff adds no dependencies, workflows, scripts, secret handling, network calls, or executable DSML parsing; remaining concerns are functional stream-filter defects.

Review findings

  • [P2] Keep DSML filter state across tool-call chunks — src/agents/openai-transport-stream.ts:1543-1544
  • [P2] Emit safe DeepSeek text without waiting for flush — src/agents/deepseek-text-filter.ts:60-62
  • [P2] Remove unrelated changelog entries — CHANGELOG.md:253-256
Review details

Best possible solution:

Keep the compat-gated suppress-only design, but preserve filter state across chunk boundaries, stream safe text promptly, remove unrelated changelog claims, and require real DSML-exercising proof before merge.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: current main appends string choice.delta.content directly to visible assistant text, and the PR's own parser tests show DSML-shaped chunks reaching this seam. I did not establish a fresh live DeepSeek response that naturally emits DSML.

Is this the best way to solve the issue?

No. The suppress-only, thinkingFormat: "deepseek"-gated direction is maintainable, but this implementation finalizes the filter too early, delays safe text streaming, includes unrelated changelog entries, and lacks DSML-exercising real proof.

Full review comments:

  • [P2] Keep DSML filter state across tool-call chunks — src/agents/openai-transport-stream.ts:1543-1544
    flushDeepSeekTextFilter() calls the filter's final flush() before same-chunk delta.tool_calls or reasoning are processed. If a DSML opener starts in that content chunk and closes in a later chunk, this clears the in-progress state or emits the partial opener, so the later DSML body/close text can leak as visible assistant text. Drain only provably safe text before changing block type, and keep DSML state for later content chunks.
    Confidence: 0.9
  • [P2] Emit safe DeepSeek text without waiting for flush — src/agents/deepseek-text-filter.ts:60-62
    When no DSML opener is present, the filter still retains MAX_OPEN_TOKEN_LEN - 1 characters unconditionally. Normal short chunks such as hello can produce no text_delta until later chunks or final flush, regressing existing streaming behavior; retain only a suffix that is actually a prefix of a DSML open token.
    Confidence: 0.88
  • [P2] Remove unrelated changelog entries — CHANGELOG.md:253-256
    This branch only changes DeepSeek stream filtering, but the changelog hunk also claims Control UI/session, Windows exec-approval, and Slack fixes. If merged, release notes would advertise fixes not delivered by this PR, so keep only the DeepSeek entry or rebase onto the commits that actually contain those fixes.
    Confidence: 0.86

Overall correctness: patch is incorrect
Overall confidence: 0.9

Acceptance criteria:

  • pnpm test src/agents/deepseek-text-filter.test.ts src/agents/openai-transport-stream.test.ts
  • pnpm check:changed

What I checked:

  • Current PR state: GitHub API reports this PR is open, draft, authored by an external contributor, and currently at head ca454a8506ccb92388c21497fc4d5eda7b40c39a with label proof: supplied. (ca454a8506cc)
  • Current main source leak path: Current main routes every string choice.delta.content text delta directly through appendTextDelta, so DSML text in that field would be appended to assistant-visible output. (src/agents/openai-transport-stream.ts:1504, 74e930870e35)
  • DeepSeek compat gate exists: Current main detects default DeepSeek OpenAI-compatible routes and assigns thinkingFormat: "deepseek", which is the generic compat contract this PR uses for gating. (src/agents/openai-completions-compat.ts:88, 74e930870e35)
  • PR finalizes DSML filter before native tool calls: At PR head, flushDeepSeekTextFilter() calls the filter's final flush() before same-chunk reasoning/tool-call handling, which can clear or emit a split DSML opener before later chunks arrive. (src/agents/openai-transport-stream.ts:1543, ca454a8506cc)
  • PR delays ordinary safe text: The new filter retains MAX_OPEN_TOKEN_LEN - 1 characters whenever no DSML opener is found, so short normal DeepSeek chunks can produce no text_delta until final flush or a later chunk. (src/agents/deepseek-text-filter.ts:60, ca454a8506cc)
  • Unrelated changelog claims: The PR changelog hunk adds Control UI, exec-approval, and Slack release-note entries even though the branch only changes DSML stream filtering files and tests. (CHANGELOG.md:253, ca454a8506cc)

Likely related people:

  • steipete: Recent GitHub commit history shows repeated maintenance of the OpenAI-compatible stream parser and compat helpers touched by this PR. (role: recent maintainer; confidence: high; commits: f3c9203631d3, 15d3fd83bb78, f52fdd855379; files: src/agents/openai-transport-stream.ts, src/agents/openai-completions-compat.ts, src/agents/openai-transport-stream.test.ts)
  • lsdsjy: Merged DeepSeek V4 support and thinking/replay behavior in the same provider family this PR changes. (role: DeepSeek feature introducer; confidence: medium; commits: 7d1891e6e63d; files: src/agents/openai-completions-compat.ts, extensions/deepseek/index.ts, extensions/deepseek/models.ts)
  • ai-hpc: Recent history shows adjacent DeepSeek V4 max-thinking-level work, making them a useful reviewer for DeepSeek-specific behavior. (role: adjacent DeepSeek maintainer; confidence: medium; commits: 797d574dfdc4; files: extensions/deepseek/models.ts, docs/tools/thinking.md, CHANGELOG.md)

Remaining risk / open question:

  • The PR body does not include after-fix real behavior proof for a DSML-bearing live DeepSeek stream; the DSML-specific proof is synthetic replay.
  • The latest head is draft and most CI checks on the head SHA are skipped, so merge readiness is unresolved.
  • The filter can still suppress intentional DSML-looking prose for DeepSeek-compatible routes, so the final tests should document that compatibility tradeoff.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 74e930870e35.

@samzong
samzong force-pushed the fix/deepseek-dsml-stream-leak branch from 4f92fdb to c42a375 Compare May 6, 2026 07:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c42a375ede

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/openai-transport-stream.ts Resolved
@samzong
samzong force-pushed the fix/deepseek-dsml-stream-leak branch from c42a375 to 4c42652 Compare May 6, 2026 07:47
@samzong samzong changed the title [Fix] suppress DeepSeek DSML leaks [Fix] handle DeepSeek DSML stream leaks May 6, 2026
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed proof: supplied External PR includes structured after-fix real behavior proof. labels May 6, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4c42652f42

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/openai-transport-stream.ts Resolved
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 6, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 6, 2026
@samzong
samzong force-pushed the fix/deepseek-dsml-stream-leak branch from 4c42652 to e867c7b Compare May 6, 2026 09:53
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. labels May 6, 2026
@samzong
samzong force-pushed the fix/deepseek-dsml-stream-leak branch from e867c7b to d5c1352 Compare May 6, 2026 10:07

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d5c1352e40

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/openai-transport-stream.ts Resolved
@samzong
samzong force-pushed the fix/deepseek-dsml-stream-leak branch from d5c1352 to 81aa7ba Compare May 6, 2026 10:53
@samzong
samzong marked this pull request as draft May 6, 2026 10:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 81aa7ba68e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/deepseek-text-filter.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b13734f6a1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/openai-transport-stream.ts Resolved
@openclaw-barnacle openclaw-barnacle Bot added triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels May 6, 2026
@samzong
samzong force-pushed the fix/deepseek-dsml-stream-leak branch from b13734f to 8efb264 Compare May 6, 2026 17:24
@samzong

samzong commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

💡 Codex Review

https://github.com/openclaw/openclaw/blob/8efb26400607a3149fd9afa2069b67f90b22afb8/src/agents/openai-transport-stream.ts#L1533-L1534
P2 Badge Preserve DSML filter state across native tool-call chunks

When a DeepSeek stream splits a DSML text span across chunks and the first content chunk also carries native delta.tool_calls, this flush treats the filter as final: flush() drops the unterminated DSML opener and resets insideDsml, so the later chunk containing the rest of the DSML body/close tag is parsed as visible text and leaks into the transcript. This breaks the split-across-chunk guarantee specifically for mixed native-tool-call chunks; the filter needs to drain safe visible text before processing tool calls without finalizing an in-progress DSML span.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@samzong
samzong force-pushed the fix/deepseek-dsml-stream-leak branch from 8efb264 to ca454a8 Compare May 9, 2026 07:42
@steipete
steipete force-pushed the fix/deepseek-dsml-stream-leak branch from ca454a8 to fb0858e Compare May 9, 2026 08:56
@steipete
steipete marked this pull request as ready for review May 9, 2026 08:56

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb0858eb9a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1530 to +1532
if (contentDelta.kind === "text") {
appendFilteredVisibleTextDelta(contentDelta.text);
} else if (currentBlock?.type === "toolCall") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Flush DeepSeek text filter before non-content deltas

When a DeepSeek content chunk ends with a possible DSML-open prefix (for example a lone <), appendFilteredVisibleTextDelta can keep that suffix buffered, but the loop immediately proceeds to reasoning/tool_calls handling without flushing the filter first. That reorders output so buffered visible text is emitted after the tool/thinking block (or only at end-of-stream) instead of at its original position, corrupting streamed transcript order for valid non-DSML text. Fresh evidence: a targeted repro with chunks "see <" then native tool_calls produced text("see ") -> toolCall -> text("<") instead of text("see <") -> toolCall.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 2807981 into openclaw:main May 9, 2026
158 of 162 checks passed
@steipete

steipete commented May 9, 2026

Copy link
Copy Markdown
Contributor

Landed with maintainer fixups. Thanks @samzong.

Proof:

Live/provider notes: native DeepSeek and OpenRouter streams used delta.tool_calls without DSML in my direct probes; NVIDIA has public DSML leak reports, but its endpoint timed out during my probe window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling proof: supplied External PR includes structured after-fix real behavior proof. size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants