这个版本更新了什么#
Breaking#
HTTPProvider.Configuration no longer takes answerTokens: Int. Use answerBudget: .tokens(n). There is no deprecated overload. HTTPProvider.answerTokens (the 1,024 default) still exists as a static.
What changed#
The four fixed limits on one HTTP answer are now configuration. Defaults match 0.5.2, so an existing caller that never set them behaves as before.
| Limit | Before | Now |
|---|---|---|
| Token budget | 1,024, fixed (0.5.3: an Int, at least 1) |
answerBudget: .tokens(n) (n at least 1) or .endpointDefault, which sends no token field so the server's own limit applies. A request without the field is never retried on a 400/422. The probe still asks for one token. |
| Timeouts | 60 s per request, 90 s overall | timeouts: Timeouts(idle:ceiling:), default 60 s idle and 90 s ceiling. The provider enforces them itself, so they now apply to an injected URLSession as well. A value over 100 years is refused at construction. |
| Reply cap | 1 MiB | responseCap, default 1 MiB. The 64 KiB cap on a refusal body stays fixed. |
| Delivery | whole reply only | delivery: .whole (default) or .streamed. A streamed request still returns one complete answer, never a partial one. The idle limit then restarts on every byte, so a slow model that keeps producing is not cut off. |
Streamed delivery builds the answer only from delta.content (reasoning deltas never reach it). A stream that ends without a finish reason is .badShape. finish_reason: "length" is still .truncated. Framing, line, event and answer caps are enforced as the bytes arrive. |
||
AIProvider and AIProviderError are unchanged. The Go side and the fixtures are unchanged. |
||
| Also: a flaky cancellation test and several wall-clock-dependent tests in the CLI and conformance suites now wait on conditions or CPU time instead of fixed delays. |
Not verified#
- 实时传送功能只在模拟服务器上测试过,没有连接真实服务。因此,真实服务会怎样分段发送内容、思考时是否会暂时没有消息,以及消息里没有 token 字段时会怎样,目前都还没有验证。
- 内存:每收到一段实时消息,解析时占用的内存会随即释放;但解析后的内容没有计入回答长度上限,URLSession 自身的缓存也没有大小限制。同一条大消息在两次测试中的内存占用结果不一致:调试版本约为 1–14 MB,另一次约为 50 MB。
spec/chat-completions.md已记录这个范围和测试结果的局限。 - 逐字节记录等待时间会带来一些开销:此前测得,传送 1 MiB 回答时约花了 140 毫秒;对于实际长度的回答,这点开销可以忽略。
Checked#
CI on macos-15 (Xcode 16) and macos-26 is green for this tag's commit. The full thread-sanitizer suite passed on a quiet 24-core Mac.
See spec/chat-completions.md, "Limits" and "Streamed delivery".
以上译自作者写在 GitHub 上的英文更新说明。查看原页面