Repository navigation
fix(ai): truncated Anthropic streams error; proxies exempt from message_stop contract - #120030
Conversation
|
Codex review: needs changes before merge. Reviewed August 7, 2026, 3:36 AM ET / 07:36 UTC. ClawSweeper reviewWhat this changesThe PR requires terminal Merge readinessKeep open: the direct-Anthropic guard is the right owner-boundary fix, but it silently turns an existing proxy-commentary test fixture into an error path while its assertions still pass. Priority: P1 Review scores
Verification
How this fits togetherThe managed Anthropic transport converts provider SSE events into normalized agent output. It must reject incomplete first-party responses without applying that framing requirement to compatible proxy endpoints. flowchart LR
A[Agent model request] --> B[Managed Anthropic transport]
B --> C[Provider SSE events]
C --> D{Direct Anthropic endpoint?}
D -->|Yes| E[Require message stop]
D -->|No| F[Accept proxy framing]
E --> G[Normalized result or error]
F --> G
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +2, Tests +83. Total +85 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the direct-service terminal-event guard, but make the proxy tool-turn test use an actual proxy identity and assert a successful terminal result before exact-head re-review. Do we have a high-confidence way to reproduce the issue? Yes—source establishes that the existing proxy-labelled fixture becomes an error after this guard while its assertions remain green because failure handling retains its output. Is this the best way to solve the issue? No—the guard is the best fix for the stream contract, but the PR must also preserve the existing proxy tool-turn test as a successful proxy case rather than silently changing its outcome. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ea4466e5dce5. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What 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 (1 earlier review cycle)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
The Anthropic SSE transport threw 'stream ended before message_stop' only when a refusal buffer happened to be non-empty, so a truncated first-party stream could pass silently while compatible proxy providers that legitimately omit message_stop failed intermittently. The invariant now keys off the transport contract owner: direct Anthropic models always require message_stop; proxy providers are exempt.
ClawSweeper P1: the proxy exemption had no focused test, so the lenient branch could regress silently. A non-anthropic provider through a custom endpoint now proves stopReason=stop with no error when the stream ends without message_stop.
e24d1c4 to
273ab83
Compare
|
Merged via squash.
|
…ge_stop contract (openclaw#120030) * fix(ai): enforce message_stop only for direct Anthropic models The Anthropic SSE transport threw 'stream ended before message_stop' only when a refusal buffer happened to be non-empty, so a truncated first-party stream could pass silently while compatible proxy providers that legitimately omit message_stop failed intermittently. The invariant now keys off the transport contract owner: direct Anthropic models always require message_stop; proxy providers are exempt. * test(ai): cover proxy streams ending without message_stop ClawSweeper P1: the proxy exemption had no focused test, so the lenient branch could regress silently. A non-anthropic provider through a custom endpoint now proves stopReason=stop with no error when the stream ends without message_stop.
What Problem This Solves
Fixes an inverted guard in the Anthropic SSE transport. The "stream ended before message_stop" check only fired when a refusal buffer happened to be non-empty — so a genuinely truncated first-party Anthropic stream (dropped connection mid-response) passed silently as a complete message, while Anthropic-compatible proxy providers that legitimately end their stream without a
message_stopevent could fail on refusal-ish content. Both directions were wrong: silent truncation on the strict contract, spurious errors on the lenient one.Why This Change Was Made
The invariant belongs to the transport contract owner. Anthropic's first-party API completes every SSE response with
message_stop(per their streaming docs), so direct Anthropic models now always enforce it. Compatible proxies aren't held to that first-party framing contract, soisDirectAnthropicModelgates the check instead of the incidental refusal-buffer state.User Impact
Truncated Anthropic streams surface as errors instead of silently delivering partial replies; proxy-routed Anthropic-compatible models stop hitting spurious message_stop failures.
Evidence
node scripts/run-vitest.mjs packages/ai/src/transports/anthropic-transport-stream.test.ts— passes, with new regression tests: direct model + truncated stream throws (with and without refusal content); proxy model + no message_stop succeeds.