Add a neutral reasoning-effort option, and stop inventing a temperature - #28
Merged
Conversation
Adds an Effort scale (none through maximum) as a chat option. Every reasoning provider spells this knob differently, so core owns the vocabulary and the level-to-budget arithmetic while each provider narrows it to what it actually offers. Also stops Agent sending temperature unless the caller chose one. It was hardcoded to 0.7 on every call, which Anthropic rejects with a 400 on Claude 4.7 and later and Google has deprecated. Inventing a sampling parameter nobody asked for was the bug underneath. Callers who relied on the implicit 0.7 will now get the model's own default.
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.
Reasoning effort
Adds
PapiAI\Core\Effort, a seven-level scale (none,minimal,low,medium,high,extra-high,maximum) exposed as aneffortchat option inChatOptions.The scale is deliberately wider than any single provider offers. Core owns the vocabulary and the level-to-budget arithmetic; each provider declares what it offers and calls
nearestOf()to narrow, so rounding is defined once rather than reinvented ten times. Ties round up: on a two-level scale a request formediumis equidistant, and quietly dropping to the floor is the more surprising outcome.Providers with no such knob ignore the option, documented per provider. Effort is a hint about quality, so being ignored degrades nothing the caller was promised. That is deliberately unlike
toolChoice, where being ignored breaks a guarantee.Temperature, a live bug
Agentsenttemperature => 0.7on every call, whether or not the caller asked for one. Anthropic returns a 400 for a non-default temperature on Claude 4.7 and later, and Google has deprecatedtemperature/top_p/top_kwith a 400 promised in a future generation. So the current release breaks outright against the newest models of two providers.AgentandAgentBuildernow take?float $temperature = nulland forward it only when set, including an explicit0.0.Behaviour change worth a changelog line: anyone relying on the implicit 0.7 now gets the model's own default instead.
Compatibility
Additive apart from the temperature default. No signature removed, no method removed,
ProviderInterfaceuntouched.241 tests, Psalm clean, 88% coverage.