Repository navigation
fix(deepseek): doubled-bar DSML tool calls are delivered as text and never executed - #128882
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 4:09 AM ET / 08:09 UTC. ClawSweeper reviewWhat this changesThe PR recognizes uniform doubled DeepSeek DSML delimiters, binds closing tags to their opening delimiter, and adds SSE-to-agent-handler regression coverage. Merge readinessNo blocking source finding on the reviewed head. The paired delimiter grammar repairs the reported recovery gap across scanning, parsing, filtering, and agent dispatch; retain this PR for exact-head CI and normal merge review. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherDeepSeek’s OpenAI-compatible stream turns SSE text into assistant text or recovered tool calls. Recovered calls enter the agent loop and can invoke registered tools, while residual DSML text is filtered before channel delivery. flowchart LR
A[DeepSeek SSE response] --> B[DSML scanner]
B --> C[DSML parser]
C --> D[Recovered tool call]
D --> E[Agent loop]
E --> F[Registered tool handler]
B --> G[Text filter]
G --> H[Visible assistant text]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +33, Tests +419. Total +452 across 5 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the single shared delimiter grammar only after exact-head checks confirm the transport, filter, and agent-loop regressions; do not add provider-specific fallback paths. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: doubled-bar DSML reaches the recovery scanner on the DeepSeek completions path, and the current-head SSE-to-agent-loop test defines the focused reproduction without requiring external credentials. Is this the best way to solve the issue? Yes: one shared uniform delimiter grammar with opener-bound closes fixes the scanner, parser, and text-filter invariant; separate hardcoded doubled-bar cases would recreate drift. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b5e8460912af. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
827f0b0 to
d3bec62
Compare
d3bec62 to
b070ebc
Compare
b070ebc to
08c77d5
Compare
Share the observed delimiter grammar between recovery and filtering, and bind each closing tag to its opener. Co-authored-by: sashankh <[email protected]>
4288096 to
53dfb34
Compare
|
@clawsweeper re-review Maintainer revision at 53dfb34 consolidates the shared grammar and exact closing-tag ownership, preserves contributor credit, removes unobserved doubled-ASCII widening, and extends existing tests. Production is net -11 lines. Baseline/fixed proof: 11 intended failures become 821 passing transport/filter tests. Real Gateway and multi-provider stress proof is in progress; exact-head CI remains required before landing. The updated body distinguishes current evidence from the superseded revision. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…never executed (openclaw#128882) * fix(deepseek): recover paired doubled DSML markers Share the observed delimiter grammar between recovery and filtering, and bind each closing tag to its opener. Co-authored-by: sashankh <[email protected]> * test: honor stream and resolved account contracts * test: prevent portal fixture from reusing its refused port --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: sashankh <[email protected]>
Closes #128858
What Problem This Solves
Fixes an issue where DeepSeek users see doubled-fullwidth DSML tool markup in a reply while the requested tool never runs. This also affects Code Mode when the recovered call is
exec.Why This Change Was Made
Recovery and visible-text filtering now share one internal delimiter grammar: the existing ASCII/fullwidth single bars and the observed doubled-fullwidth form. Each invocation, parameter, and suppressed block must close with its opening marker. The scanner carries the exact pending invocation close instead of independent mode/sentinel state and redundant close-token lists.
This maintainer revision preserves @sashankh's fix and credit while consolidating the implementation and extending existing fixtures. It does not add unobserved doubled-ASCII syntax, configuration, public exports, storage, retries, or a provider fallback. The 256 KB buffer cap, nested-wrapper rejection, and stop/length/refusal authorization boundary remain intact.
User Impact
Recognized doubled-bar tool calls execute normally and their markup does not leak into replies. Malformed mixed markers and foreign closing tags cannot authorize a tool invocation. Single-bar output keeps working.
Evidence
On baseline
bcac331e0746, the new/extended tests produce 11 intended failures: eight recovery/transport failures and three text-filter failures. On this revision, all 821 tests across 52 transport/filter files pass. Coverage includes character-by-character chunks, real HTTP/SSE, successful stop versus length/content-filter terminals, existing buffer/nesting/surrogate limits, and malformed delimiter rejection. Fresh independent Codex autoreview found no actionable findings at its P0 threshold.Production LOC: +60/-71 (net -11). Tests: +99/-55 (net +44). This replaces duplicated delimiter policy and scanner state rather than adding a second parsing path.
The official DeepSeek V4 encoder uses single fullwidth bars; the doubled form is the reporter's observed provider output, not a claim about the documented encoder. Final-effect proof used real HTTP/SSE through an isolated built Gateway, the managed DeepSeek transport, Code Mode, and the real write handler. Before the patch, doubled bars leaked and wrote nothing; an asymmetric inner invocation wrongly wrote the nonce file. After the patch, single/doubled forms each execute exactly once with the exact nonce file, while mismatched/asymmetric forms execute zero tools and create no file. No DSML appears in the delivered reply. The provider socket is synthetic in this deterministic reproduction, not presented as an actual DeepSeek emission.
Authenticated
deepseek/deepseek-v4-flashthrough the same Gateway also completed read/calculate/write/readback, background process polling, three yields, caught and uncaught errors, sixteen-call fan-out, and timer/catalog composition. The completed seven-model stress results are recorded below. We did not observe the intermittent doubled-bar emission from the real provider in this sample.Local full compilation completed, but its postbuild checker hit stale workspace-package exports in the borrowed dependency tree. An isolated runtime linked to this checkout's freshly built packages passed the same canonical native control-plane check (49 modules) and served the live proofs. The shared dependency tree was not modified. Hosted changed checks passed; all final-head CI checks passed before the native prepare/merge flow.
Provenance: the single-bar filter originated in @samzong's #78331 (merged by @steipete, May 9); recovery originated in @steipete's #88946 (also merged by @steipete, June 2). The August #122122 split carried the assumption forward rather than introducing it. GitHub timelines show no recorded automerge enablement/trigger for the original merges.
Review follow-through: the prior review's boundary-proof and exact-head-CI requests remain landing gates. Its production-growth concern is resolved by the net-negative consolidation. The automated persistent-data warning is inapplicable: only transient parsing and tests change; no SQLite/schema/state format changes. Native Codex's separate V8/freeform protocol is untouched; OpenClaw's managed completions transport owns this fix.
Named follow-up: historical/imported transcript stripping in
src/hooks/bundled/session-memory/transcript.tsindependently recognizes single-bar DSML. This transport repair prevents new doubled-bar leakage but does not rewrite or repair historical transcript projections. General malformed proxy output (#114888) remains separate.CI follow-up at
fa78b88a7422: await the stream factory's declared sync/async union in the HTTP fixture (the runtime result was already synchronous and passing), and correct one inherited Twitch test assertion to expect the resolved default account. The two Twitch failures came from #132226 normalizing account identity after #131689 introduced the fixture. Request omission remains tested; only the downstream expected resolved account changes. All 128 gateway-send tests pass. Fresh autoreview of both fixture corrections is clean. No production behavior changed after the live Gateway build.Stress result: 77 primary live cases across OpenAI GPT-5.6 Luna/Terra/Sol, Claude Sonnet 4.6/Haiku 4.5, Gemini 3.5 Flash, and DeepSeek V4 Flash; plus 14 concurrent sessions. All returned HTTP 200. Strict transcript/file verification found three model adherence failures (Haiku shell sessionId passed to outer wait; Gemini shadowed text(); DeepSeek omitted return), preserved as failures rather than counted as runtime passes. Explicit corrected code passes for Gemini and DeepSeek. Haiku background recovery remains an open product case tracked by #128859/#128886. File outcomes, yield chains, bounded errors, pending-call rejection without writes, and post-timeout recovery are inspected independently of final response prose. Where nested readback/process receipts are absent, proof is labeled partial rather than inferred.
Final CI stability follow-up: the unrelated portal refusal fixture released its target port before allocating the Gateway. A controlled real-socket reproduction forcing reuse produced a successful connection and one readiness frame (the same unexpected resolved outcome as CI); allocating the Gateway first produces ECONNREFUSED and zero readiness frames. The test now allocates the Gateway first. This is a test-only setup reorder, no production change; all23 portal/stream sibling tests and fresh autoreview pass. The CI log lacks port identities, so attributing that particular run to reuse remains an inference; the underlying fixture race is directly reproduced and removed. Test LOC includes an additional +11/-11 move (discounted as a pure move, net0).
Landed as 8af1b4aceeab. Final head a382bf8 passed CI; the hosted changed-file check passed exit0. The merged production files were compared byte-for-byte with the live-tested build and are identical. #128858 is closed as completed.