Repository navigation
Conversation
HTTPTransport is a protocol for how a model sends its HTTP requests: perform(request:body:timeout:responseHandler:) on swift-http-types, reading the response's body as it arrives, only in the handler. URLSession and AsyncHTTPClient's HTTPClient conform, and a caller can supply its own as a model's `session`, to decide how requests are sent or to observe them. What every request is made of, decoding JSON, JSON lines and server-sent events, is now written once on top of it instead of once per client, and providers build HTTPRequests with typed fields. HTTPSession and makeDefaultSession() stay as they were.
A caller can now tell a transport failure apart and read an error response whole: its status, its headers, such as Retry-After, and its body.
Collaborator
|
Thanks, @akbashev. Sending Ollama's thinking back each round makes sense. Two things:
One question: when streaming, does the final round's reasoning make it into the transcript? It looks like it's appended after the last snapshot. |
# Conflicts: # Sources/AnyLanguageModel/Models/AnthropicLanguageModel.swift # Sources/AnyLanguageModel/Models/GeminiLanguageModel.swift
Contributor
Author
|
Merged the updated #340 in and formatted with swift-format. |
# Conflicts: # Sources/AnyLanguageModel/Models/OllamaLanguageModel.swift
- The requirement is `send(request:body:timeout:responseHandler:)`, and its doc comment states the contract: the handler runs at most once, cancelling the task cancels the request, the body can't be read after the handler returns, a transport doesn't retry once it has passed a response on, and `timeout` is how long to wait for the response to start, from when the transport decides. - Remote models take `transport: any HTTPTransport = makeDefaultTransport()`. `session:` stays as a deprecated overload with no default, and `HTTPSession` and `makeDefaultSession()` are deprecated. - `HTTPResponseBody` yields chunks of `Data`. URLSession reads them with a task delegate on Apple platforms, which keeps the session's connections, and AsyncHTTPClient passes on its buffers. - `HTTPTransportError` is a struct with a `kind`, so kinds can be added in 1.x, and the response and its body as `Data`, both optional. - `FakeTransport` and `HTTPTransportTests`: a model's request, JSON, JSON lines and events split across chunks, and an error response's headers and body.
Ollama's provider read no thinking from responses, so a reasoning model such as DeepSeek began again after every tool call. Its thinking is now kept as a reasoning entry and sent back as the message's `thinking`, in the tool loop and from the transcript. Reasoning carries a typed `Origin`, which Anthropic's provider uses too: each provider gives back only its own.
akbashev
force-pushed
the
fix/ollama-reasoning-replay
branch
from
October 18, 2026 13:44
84f2962 to
2ddebb7
Compare
Contributor
Author
|
Rebased on #340 as you asked, and its tests now use #340's
|
Collaborator
|
Thanks, @akbashev. Both changes look good. One more case: |
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.
Builds on #340. Only the last commit, "Give Ollama's reasoning back to it in each tool round", belongs to this PR. Its tests use #340's
FakeTransport.Ollama's provider didn't read
thinkingfrom responses, so a reasoning model such as DeepSeek started its reasoning over after every tool call. Its thinking is now:thinking, both in the tool loop and when the transcript is replayed.Reasoning now carries an internal
Origin, which Anthropic's provider uses too, so each provider gives back only its own reasoning.When streaming, the final round's reasoning is in the last snapshot.