Repository navigation
Update optional derivation narration to Claude Sonnet 5.5 - #581
Merged
Merged
Conversation
Rebuilt on origin/main (6a9c878) from the 2026-09-28 model-pin audit's salvaged lane work (refs/salvage/model-pins-2026-09-28/PolicyEngine__policyengine.py, 8fa112335). - No build-lane report survived for this edit; it is re-verified from scratch in this branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Name the changelog fragment after issue #580, as the repository's PR guide requires. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Validate effective LiteLLM AnthropicConfig before synchronous and asynchronous requests for both supported model spellings without mutating shared settings. Add 24 regression cases, preserve custom-model behavior and compatible token defaults, and update the issue #580 changelog fragment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 tasks done
Keep the main request defaults for custom models in both narration APIs. Use the same error for missing choices and missing text, and document which provider supplies credentials. Co-Authored-By: GPT-6.2 Sol <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A 4,096 cap on explicit budgets passed the [None, 512] cases; the 8,192 case fails on it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
marked this pull request as ready for review
December 3, 2026 02:58
Contributor
Author
|
Merging at
|
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.
Fixes #580
Optional derivation narration (
narrate()andnarrate_async()) moves from Claude Sonnet 4.6 to Claude Sonnet 5.5. A new optionalnarrationextra installs LiteLLM 1.103.0, and thedevextra pins the same version. The base install gains no dependencies.uv.lockadds 27 packages, LiteLLM and 26 of its dependencies, and movespydantic-settingsfrom 2.10.1 to 2.15.0. This PR leaves the country-package, PolicyEngine Core and SPM Calculator pins unchanged.What changes for callers
481940eca187c81e0cclaude-sonnet-4-6claude-sonnet-5-5at low efforttemperature=with the default modelValueErrorfor any value other thanNoneAnthropicConfigtemperature,top_portop_k, with the default modelValueErrormax_tokens=500,temperature=0.0IndexErrororAttributeErrorValueErrorpolicyengine[narration]installs 1.103.0How narration calls each model
claude-sonnet-5-5oranthropic/claude-sonnet-5-5): narration sends the request through LiteLLM's Anthropic provider with Anthropic credentials,output_config.effort="low"and a defaultmax_tokens=4096. A caller can override the token budget. Narration omitsthinking, so adaptive thinking applies, and the budget covers thinking and text (Anthropic's effort docs). Output length and token use can vary. Before it sends a model request, narration raisesValueErrorif the caller passes atemperatureother thanNone, if LiteLLM's globalAnthropicConfigsetstemperature,top_portop_k, or if LiteLLM parameter dropping is on, since dropping can discard the required effort setting.model=: narration uses the selected provider's credentials. It passesmax_tokens=500andtemperature=0.0to LiteLLM by default and passes explicit overrides when supplied. LiteLLM and the selected model must support the supplied values. For example, with parameter dropping off (the default), LiteLLM 1.103.0 rejects both the defaulttemperature=0.0and an explicit 0.2 foropenai/gpt-5.Both functions return the narrated text and raise
ValueErrorfor a refusal, missing or blank text, or a response with no choices. The README explains which credentials each route needs.Verification
Tests ran serially on CPython 3.14.10 after
uv sync --locked --extra dev, without network access and with mocked provider responses.229f07ff8tests/test_derivations.py229f07ff8tests/test_derivations.pyfrom187c81e0c229f07ff8, patched so Sonnet requests always sendmax_tokens=4096tests/test_derivations.py229f07ff8, patched so Sonnet requests always sendmax_tokens=4096tests/test_derivations.py187c81e0ctests/test_derivations.py187c81e0ctests/229f07ff8, the unchanged code passes all 73 expanded tests. A patch that makes Sonnet requests ignore the caller'smax_tokensstill passes the original 65 tests but fails the eight new 512-token cases.cb2ebc60e, the mocked HTTPX test also sends an explicit 8,192-token budget, so a change that caps a caller's budget at 4,096 fails it.187c81e0c, which had 1,255 passed, 9 skipped and 16 setup errors. With public PyPI metadata forpackaging26.2 cached,tests/test_release_lock.pypassed all 25 tests; the 16 errors came from that missing metadata. With a local-wheel manifest built from the pinned PyPI wheels, whose hashes matchuv.lock, the five tests intests/test_spm_development_authentication.pypassed; they skip without a manifest.narrate()andnarrate_async()for both Sonnet spellings, with the default and explicit 512- and 8,192-token budgets. They also check a response with a thinking block and two text blocks, and a refusal.229f07ff8and187c81e0c, callednarrate()andnarrate_async()withmodel="openai/gpt-5". LiteLLM 1.103.0 raisedUnsupportedParamsErrorfortemperature0.0 and 0.2 before any provider POST. With parameter dropping on, direct LiteLLM calls strippedoutput_configwith the model map bundled in the wheel, which has no Sonnet 5.5 entry. They kept it with the current public model map, which marksclaude-sonnet-5-5withsupports_output_config. Narration raisedValueErrorfor parameter dropping with both Sonnet spellings under either map, before any POST.187c81e0c, the four remaining skips, intests/test_be_axiom_pilot.py, need unpublished Belgium pilot source packages. The credentialed release checks needHUGGING_FACE_TOKENand did not run locally. CI's release-input job ran them and passed at187c81e0c.187c81e0c,make lintpassed its format check and lint locally under Ruff 0.17.6, and CI's Lint job passed. The changelog check,uv lock --check,uv pip checkandscripts/release_lock.pyalso passed. The locked Ruff 0.12.11 reports the same 11 UP038 diagnostics at229f07ff8and187c81e0c.🤖 Generated with Claude Code