Repository navigation
Swift: every published failure is an AgentsError - #2798
Merged
Merged
Conversation
martinmitrevski
force-pushed
the
fix/swift-one-failure-type
branch
from
November 30, 2026 17:29
5612932 to
ad62613
Compare
Conversation.failure was the error frame's text and is now .reported(code:message:), and VoiceSession.failure was any Error and now wraps Stream Video's errors as .transport. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
martinmitrevski
force-pushed
the
fix/swift-one-failure-type
branch
from
November 30, 2026 17:40
ad62613 to
05bb062
Compare
…s context VoiceSession's mute and camera paths could store a CancellationError as a transport failure; AgentSession's mapping, which never did, is now AgentsError(reporting:) and both use it. .reported carries the error frame's context, and .transport says it also holds a call's failures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
martinmitrevski
marked this pull request as ready for review
December 1, 2026 10:17
👋 Thanks, Martin! I'm on it.How to work with me
CommandsComment any of these on the PR:
|
There was a problem hiding this comment.
Round 1 · 🆕 3 new · 1 should-fix to go
| Finding | Where | |
|---|---|---|
| 🟡 Should Fix | Kotlin SessionSocket entry is already in the changelog | CHANGELOG.md:727 |
➡️ Round 2 started on 2255e75.
- An error frame with no sentence for a person gave .reported an empty description, so a banner showing it was blank. It now says what the frame does say: "the agent reported a failure in llm (rate_limited)", or just the first part when it names neither. - CHANGELOG: drop the Kotlin SessionSocket line the merge from main repeated (main keeps the fuller #2775 one), and say that .transport's description now starts "could not get through". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The SDK published
failurewith three types:AgentsError?onAgentSession,String?onConversationand(any Error)?onVoiceSession. An app showing why something went wrong handled each differently, andConversation's string threw away thecodethe router sends beside the words (prompt_injection,invalid_image), which is what a program should branch on. From the pre-release audit of the Swift SDK.The question was whether to build on StreamCore's
ClientErrorinstead. This keepsAgentsError:ClientError'sAPIErroris Stream Chat and Video's error body (a numericcode,statusCode,details,moreInfo), not the router's (typeandcodeas strings,doc_url), and its subclasses can't be switched over exhaustively.How it works
failureonAgentSessionAgentsError?ConversationString?, theerrorframe's textAgentsError?:.reported(code:context:message:)(new case)VoiceSession(any Error)?AgentsError?: Stream Video's, the microphone's and the camera's errors as.transport, the SDK's own as they were, a cancellation neverConversation.failureis now read-only..transportreads "could not get through" rather than "could not reach the router", since on a voice session it now also carries what Stream Video, the microphone or the camera failed with; its doc and the skill's rule say so.AgentsError(reporting:)is the one mapping, moved fromAgentSession's private helper: a cancellation is no failure, the SDK's own errors keep their case, anything else is.transport.VoiceSession's join, mute and camera paths andAgentSession's socket all use it.swift_assistant'sAgentChatshowsfailure?.localizedDescription.sdk-swiftskill says everyfailureis anAgentsError, and why notClientError..claude/skills/sdk/notes/2026-11-30-one-failure-type.mdsays where Kotlin and Dart have the same three shapes.Validation
ConversationTests/aRefusedReplyLosesWhatItWroteBeforeTheVerdictAndKeepsHowItGotThere(now checks the case)code; checked by mutationConversationTests/aReportedFailureIsKeptRatherThanThrown(now checks the case)VoiceSessionTests/aJoinTheSDKCannotMakeSaysHowToSetItUp(new).configurationburied in a.transport; checked by mutationVoiceSessionTests/aJoinWhileOneIsUnderWayReturnsAtOnce,aJoinThatFailedCanBeTriedAgain(now check the case).transportBackendTests/aCancellationIsNoFailureAndTheSDKsOwnAreNotWrapped(new)detachingClosesTheSocketAndLeavesTheSessionRunningtime out on its close frame; it passed alone and in the next full run. That is the known flaky socket-close test, which this PR doesn't touch.swift_demoandswift_assistantbuild for the simulator. Not run.Self-review (a fresh read of the diff) changed three things:
VoiceSession's mute and camera paths could have stored aCancellationErroras.transport; they now shareAgentsError(reporting:)..reportedkeeps the frame'scontext, the only field a program could branch on for a failure that isn't a refusal..transport's docs no longer say it is only the network.It also fixed the note's citations and the test's labels. No test covers a real Stream Video error, since none joins a call.
Breaking:
Conversation.failureandVoiceSession.failurechange type, andConversation.failureis read-only.AgentsErrorgains a case, so aswitchover it needs.reported.One line under
# Unreleased→ Breaking Changes.🤖 Generated with Claude Code