Repository navigation
Streamed turns now report usage and can carry opaque provider state for
verbatim replay (#182); temperature becomes optional for reasoning models;
and the supported SDK ranges widen to openai 2.x/3.x and anthropic 1.x.
Added
StreamEnd: usage and provider state at the end of a native stream
(#182). Providers may yield oneselectools.types.StreamEndas the last
item ofstream()/astream(). Itsusageis counted intoagent.usage,
passed toon_llm_end/on_usage, and recorded on theLLM_CALLtrace
step; before this, every streamed turn reachedon_llm_endwithNone
usage and was missing from the totals. Itsprovider_stateis copied onto
the assistantMessagethe agent assembles from chunks. The agent consumes
the item; consumers that pattern-match onstr/ToolCallare unaffected.
The OpenAI provider now emits it from the usage chunk it already requested
onastream(), and requests it onstream()too.Message.provider_state— an opaque, JSON-safe dict a provider attaches
to an assistant message so it can replay that turn verbatim on the next
request (stateless Responses-style APIs with encrypted reasoning items).
Carried through the tool loop,ConversationMemorycopies,
to_dict()/from_dict(), and the cache key. Replaces smuggling such
state throughToolCall.thought_signature.
Changed
temperatureisOptional[float]onAgentConfigand every provider
method.Nonemeans "send no temperature", which reasoning models
require; the OpenAI-compatible and Anthropic providers omit the field
instead of relying on the 400-and-retry fallback. The default stays0.0,
so no existing output changes.- Streamed turns on
run()/arun()now record anLLM_CALLtrace step
(previously onlyastream()did). - Supported SDK ranges are now
openai>=1.55.3,<4and
anthropic>=0.40.0,<2(previously>=1.30,<2and>=0.28,<1). The new
majors are drop-in for the surface selectools uses (chat.completions,
embeddings,images,messages); their breaking changes are thehttpx
tohttpx2swap (only matters if you handhttpxobjects to the SDK
clients) and, for anthropic 1.0, the removal oftemperature/top_p/
top_kfrom themessages.create()signature. The floors were raised
because the old ones never resolved to a working install: with httpx 0.28
(which a fresh resolve picks)openai<1.55.3andanthropic<0.40fail at
client construction withunexpected keyword argument 'proxies'.
anthropic 2.x stays unsupported: it sends API version2026-10-21, which
returns 400 for anytemperature(even the default), and the provider
sendstemperature=0.0by default. - The Anthropic provider now sends
temperaturethroughextra_bodyinstead
of as a keyword argument, so a non-Nonetemperature no longer raises
TypeError(surfaced asProviderError) on anthropic >= 1.0. The request
JSON is identical on every supported SDK version. New wire-level tests
(tests/providers/test_sdk_compat.py, from #184) drive the real SDK
clients through a mock HTTP transport so signature drift like this fails
CI, and pin the Anthropic API version the installed SDK sends.
pip install -U selectools==1.4.0