You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/AgentRunKit/Documentation.docc/Articles/LLMProviders.md
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -217,10 +217,23 @@ All clients accept a ``RetryPolicy`` controlling retry behavior on transient fai
217
217
|`maxAttempts`| 3 | Total attempts before failing |
218
218
|`baseDelay`| 1 second | Initial backoff duration |
219
219
|`maxDelay`| 30 seconds | Cap on exponential backoff |
220
-
|`streamStallTimeout`| nil |Restarts a stream if no delta arrives within this duration |
220
+
|`streamStallTimeout`| nil |Fails a stream with ``StreamFailure/idleTimeout(diagnostics:)`` when no bytes arrive within this duration |
221
221
222
222
Two static presets: `.default` (3 attempts, 1s base, 30s max) and `.none` (single attempt, no retries).
223
223
224
+
Retries apply before a stream starts; once a 2xx byte stream is open, failures propagate to the caller as typed ``StreamFailure`` values rather than being retried.
225
+
226
+
## Stream Termination
227
+
228
+
Each streaming transport defines exactly which wire conditions end a stream successfully; anything else throws a typed ``StreamFailure``.
229
+
230
+
- OpenAI-compatible Chat Completions: a `data: [DONE]` sentinel completes the stream immediately. A terminal non-`error``finish_reason` also marks the turn complete, so a stream that ends at EOF after one is a successful completion (reported through ``StreamCompletionDiagnostics/terminalMarkerSeen``). Frames carrying a top-level `error` payload, or `finish_reason: "error"`, throw ``StreamFailure/providerError(code:message:diagnostics:)`` with the upstream code and message preserved. EOF with no finish signal throws ``StreamFailure/providerTerminationMissing(diagnostics:)``, and a `[DONE]` with no preceding finish signal throws ``StreamFailure/finishedDeltaMissing(diagnostics:)``.
231
+
- Anthropic (and Vertex Anthropic): `message_stop` completes the stream; `error` events throw ``StreamFailure/providerError(code:message:diagnostics:)``; EOF before `message_stop` throws ``StreamFailure/providerTerminationMissing(diagnostics:)``.
232
+
- Gemini (and Vertex Gemini): a chunk with `finishReason` completes the stream; error envelopes throw ``StreamFailure/providerError(code:message:diagnostics:)``.
233
+
- Responses API: `response.completed` and `response.incomplete` complete the stream; `response.failed`, `response.error`, and standalone `error` events throw ``StreamFailure/providerError(code:message:diagnostics:)``.
234
+
235
+
Every failure carries ``StreamFailureDiagnostics`` identifying the provider, elapsed time, events observed, and whether a finish signal had been seen before the failure.
0 commit comments