Skip to content

Add a neutral reasoning-effort option, and stop inventing a temperature - #28

Merged
MarcelloDuarte merged 1 commit into
mainfrom
reasoning-effort
Jul 31, 2026
Merged

Add a neutral reasoning-effort option, and stop inventing a temperature#28
MarcelloDuarte merged 1 commit into
mainfrom
reasoning-effort

Conversation

@MarcelloDuarte

Copy link
Copy Markdown
Contributor

Reasoning effort

Adds PapiAI\Core\Effort, a seven-level scale (none, minimal, low, medium, high, extra-high, maximum) exposed as an effort chat option in ChatOptions.

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 for medium is 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

Agent sent temperature => 0.7 on 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 deprecated temperature/top_p/top_k with a 400 promised in a future generation. So the current release breaks outright against the newest models of two providers.

Agent and AgentBuilder now take ?float $temperature = null and forward it only when set, including an explicit 0.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, ProviderInterface untouched.

241 tests, Psalm clean, 88% coverage.

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.
@MarcelloDuarte
MarcelloDuarte merged commit 62382e7 into main Jul 31, 2026
6 checks passed
@MarcelloDuarte
MarcelloDuarte deleted the reasoning-effort branch July 31, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant