Repository navigation
fix(agents): cap DeepSeek DSML recovery buffer at 256 KB - #117175
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 10:56 AM ET / 14:56 UTC. ClawSweeper reviewWhat this changesCaps DeepSeek textual DSML recovery at 256 KB, rejects unsafe wrapper boundaries, and adds stream-level regressions for overflow and valid recovery. Merge readinessThis PR remains necessary: current Priority: P1 Review scores
Verification
How this fits togetherThe OpenAI-compatible completions transport turns provider SSE content into agent text and tool-call events. For DeepSeek-compatible models, textual DSML markup passes through a recovery stage before it can emit a recovered tool call. flowchart LR
A[Provider SSE content] --> B[Completions transport]
B --> C[DeepSeek DSML recovery]
C --> D{Bounded valid markup?}
D -->|yes| E[Recovered tool-call events]
D -->|no| F[Text or transport error]
E --> G[Agent output]
F --> G
Decision needed
Why: The implementation is coherent with sibling stream caps, but whether existing oversized textual DSML responses may fail visibly is a product and upgrade compatibility choice. Before merge
Agent review detailsSecurityNone. PR surfaceSource +192, Tests +396. Total +588 across 2 files. View PR surface stats
Review metricsNone. 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: Keep a single bounded recovery path before tool-event authorization, and merge it only after the transport owner explicitly accepts the 256 KB terminal-error compatibility contract. Do we have a high-confidence way to reproduce the issue? Yes: current Is this the best way to solve the issue? Yes, pending compatibility acceptance: the cap and wrapper scan are placed at the DSML recovery owner before it can emit a tool call, rather than masking the condition downstream. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5ad7c969b820. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
Unterminated DSML tool-call recovery buffered provider text without a byte limit, so a malicious or buggy stream could grow gateway memory without bound while waiting for a close token. Add MAX_DSML_RECOVERY_BUFFER_BYTES (256_000), matching the existing tool-call argument and post-tool text caps, and enforce it with UTF-8 Buffer.byteLength accounting so multibyte payloads cannot bypass a string-length check. Fixes openclaw#90015 Signed-off-by: Sebastien Tardif <[email protected]>
f4777ec to
ac5fe2b
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
ac5fe2b to
85cf038
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Maintainer decision: accepted. The 256 KB cap intentionally trades recovery of exceptionally large textual DSML blocks for bounded gateway memory and deterministic failure. It matches the existing tool-call/post-tool buffer budget, rejects malformed or nested recovery structures, and preserves ordinary DeepSeek tool-call recovery. The remaining pathological 256k one-character streaming case is bounded and non-blocking; no broader parser rewrite is warranted for this fix. |
* origin/main: (99 commits) test: consolidate agent tool suites (openclaw#117886) fix: remove duplicate plugin CLI registry mock (openclaw#117894) fix(gateway): resume shared terminal after slow viewer leaves (openclaw#117847) refactor(gateway): remove deferred channel load flag; 503 plugin routes until runtime ready (openclaw#117852) test(agents): consolidate OpenClaw tool suites (openclaw#117870) fix(ci): repair release validation regressions (openclaw#117723) fix(media): reject empty generated assets (openclaw#117875) fix: release channel delivery resources reliably (openclaw#117855) refactor(cli): unify config-guard policy across dispatch paths (openclaw#117880) test: consolidate WhatsApp monitor suites (openclaw#117854) fix(heartbeat): retain configured account for accountless commitments (openclaw#117521) fix(agents): cap DeepSeek DSML recovery buffer at 256 KB (openclaw#117175) [AI] fix(line): downgrade row-overflow tables to ordered bullet text (openclaw#117481) fix(agents): fallback after replay-safe silent errors (openclaw#117356) fix(telegram): serialize approval ingress sessions (openclaw#117861) fix(agents): report truthful embedded startup stages (openclaw#117879) test(sqlite): align flip-proof request budgets (openclaw#117878) fix(ui): advance gateway-owned channel setup progress (openclaw#117877) fix(media): preserve canonical attachment facts across every agent owner (openclaw#117841) test(protocol): consolidate validation fixtures (openclaw#117873) ...
…7175) Co-authored-by: Sebastien Tardif <[email protected]>
Fixes #90015
Recreates closed #86637 (barnacle inactivity auto-close) on current main.
What Problem This Solves
DeepSeek-compatible providers can stream textual DSML tool-call markup. An unterminated outer DSML block previously grew the recovery buffer without a bound, allowing a buggy or hostile stream to consume memory for the lifetime of the response.
Why This Change Was Made
The DSML recovery owner now enforces a 256 KB UTF-8 limit, matching the existing native tool-call argument and post-tool text limits.
Exceeded DeepSeek DSML recovery buffer limit.The explicit transport error is intentional: it gives the operator and retry layer a visible outcome instead of silently discarding the remainder of the response or guessing where nested recovery can resume.
No config, protocol, or public API surface changes.
User Impact
Malformed or malicious DeepSeek DSML streams can no longer grow recovery memory without bound. Valid DSML calls at or below the limit continue to recover normally. Valid textual DSML blocks above 256 KB now fail visibly; maintainers accept that compatibility tradeoff because it matches the existing native tool-call safety envelope.
Evidence
Exact repaired head:
440804456395c8bbcfb319e93c4cccc9e3d86e11Sanitized exact-head AWS proof
The standalone script used
createOpenAICompletionsTransportStreamFn()directly against a loopback OpenAI-compatible SSE endpoint, without Vitest or test-support imports:{"exactHead":"440804456395c8bbcfb319e93c4cccc9e3d86e11","oversized":{"terminal":"error","reason":"error","errorMessage":"Exceeded DeepSeek DSML recovery buffer limit","toolEvents":0},"nested":{"terminal":"error","reason":"error","errorMessage":"Nested DeepSeek DSML recovery wrappers are not supported","toolEvents":0},"namelessInvoke":{"terminal":"done","reason":"stop","toolEvents":0},"valid":{"terminal":"done","reason":"toolUse","toolName":"message","arguments":{"text":"literal <|DSML|tool_calls> marker"}}}Coverage includes:
Review and static proof
git diff --check: passoxfmt --checkon both changed files: pass0.99+195/-17(+178net); tests:+363/-28The positive production delta is the bounded structural scanner and byte-accounting owner needed to prevent provider text from crossing into executable tool-call events through malformed wrapper boundaries.
check-lintjob that was terminated by runner shutdown on attempt 1