Skip to content

SWF(bug): surface Anthropic stream errors and refusals - #46

Merged
maplepaladin73 merged 1 commit into
mainfrom
devin/1795371434-anthropic-stream-outcomes
Nov 22, 2026
Merged

maplepaladin73 merged 1 commit into
mainfrom
devin/1795371434-anthropic-stream-outcomes

Conversation

@maplepaladin73

@maplepaladin73 maplepaladin73 commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

Anthropic streams now end with an SSE error on upstream failure and report model refusals as stop_reason: "refusal" without repeating the refusal text.

Test plan

Before (Spark binary with tests only):

stream_error_is_not_reported_as_success: ["message_start", "message_delta", "message_stop"] != ["error"]
stream_error_interrupts_an_open_block: got content_block_stop and message_stop instead of error
stream_error_closes_the_sse_body: error must close the SSE body without waiting for upstream EOF: Elapsed(())
stream_refusal_sets_stop_reason_without_repeating_text: "end_turn" != "refusal"
test result: FAILED. 5 passed; 4 failed

After (same regressions in the full Spark binary suite, after rebasing):

test anthropic::tests::translator_stream::stream_error_is_not_reported_as_success ... ok
test anthropic::tests::translator_stream::stream_error_interrupts_an_open_block ... ok
test anthropic::tests::translator_stream::stream_error_closes_the_sse_body ... ok
test anthropic::tests::translator_stream::stream_refusal_sets_stop_reason_without_repeating_text ... ok
test result: ok. 3203 passed; 0 failed; 14 ignored

Root cause: The translator discarded both deltas, so EOF synthesized a successful end after errors, and a regular Finish delta still reported end_turn on refusals. Errors now emit the Anthropic error envelope and end the SSE body without a success frame. The refusal annotation changes only the stop reason; normal text and final token usage are preserved.

Try it (GPU-free, with scripts/ci_gpu_stubs.sh setup):

ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-server --bin spark anthropic::tests::translator_stream

Blueprint lint: Formatting, workspace Clippy, license headers and typos passed on the rebased branch. The main build fix is now in the base; no local source workarounds were needed.

Untested: Real-model inference and GPU/Docker validation. The SSE test runs the real HTTP body encoder using an injected upstream error.

CLA


Software Factory opened this PR for Robert
Implemented in session Surface errors and refusals in Anthropic streams
Review with Devin · Open in Devin Desktop


@devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1795371434-anthropic-stream-outcomes branch from 2f07402 to 4e34384 Compare November 22, 2026 18:28
@maplepaladin73
maplepaladin73 merged commit a10ab81 into main Nov 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant