Skip to content

Update optional derivation narration to Claude Sonnet 5.5 - #581

Merged
MaxGhenis merged 7 commits into
mainfrom
chore/model-pins-2026-10-03
Dec 3, 2026
Merged

MaxGhenis merged 7 commits into
mainfrom
chore/model-pins-2026-10-03

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #580

Optional derivation narration (narrate() and narrate_async()) moves from Claude Sonnet 4.6 to Claude Sonnet 5.5. A new optional narration extra installs LiteLLM 1.103.0, and the dev extra pins the same version. The base install gains no dependencies. uv.lock adds 27 packages, LiteLLM and 26 of its dependencies, and moves pydantic-settings from 2.10.1 to 2.15.0. This PR leaves the country-package, PolicyEngine Core and SPM Calculator pins unchanged.

What changes for callers

Behavior Before, at merge base 481940eca After, at 187c81e0c
Default model claude-sonnet-4-6 claude-sonnet-5-5 at low effort
Default token budget for the default model 500 4,096, covering thinking and text
temperature= with the default model Sent; default 0.0 Raises ValueError for any value other than None
Parameter dropping, or global AnthropicConfig temperature, top_p or top_k, with the default model Not checked Raises ValueError
Defaults for other models max_tokens=500, temperature=0.0 Unchanged
Refusal, blank text or no choices Returned the stripped text, or raised IndexError or AttributeError Raises ValueError
LiteLLM Not declared; callers installed it policyengine[narration] installs 1.103.0

How narration calls each model

  • Sonnet 5.5, the default (claude-sonnet-5-5 or anthropic/claude-sonnet-5-5): narration sends the request through LiteLLM's Anthropic provider with Anthropic credentials, output_config.effort="low" and a default max_tokens=4096. A caller can override the token budget. Narration omits thinking, 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 raises ValueError if the caller passes a temperature other than None, if LiteLLM's global AnthropicConfig sets temperature, top_p or top_k, or if LiteLLM parameter dropping is on, since dropping can discard the required effort setting.
  • Other models selected with model=: narration uses the selected provider's credentials. It passes max_tokens=500 and temperature=0.0 to 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 default temperature=0.0 and an explicit 0.2 for openai/gpt-5.

Both functions return the narrated text and raise ValueError for 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.

Code Run Result
229f07ff8 Original tests/test_derivations.py 65 passed
229f07ff8 Expanded tests/test_derivations.py from 187c81e0c 73 passed
229f07ff8, patched so Sonnet requests always send max_tokens=4096 Original tests/test_derivations.py 65 passed
229f07ff8, patched so Sonnet requests always send max_tokens=4096 Expanded tests/test_derivations.py 65 passed, 8 failed (every Sonnet case with an explicit 512-token budget)
187c81e0c tests/test_derivations.py 73 passed
187c81e0c Rest of tests/ 1,276 passed, 4 skipped
  • Rows two to four show that the new tests catch a lost token budget. At 229f07ff8, the unchanged code passes all 73 expanded tests. A patch that makes Sonnet requests ignore the caller's max_tokens still passes the original 65 tests but fails the eight new 512-token cases.
  • At 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.
  • The last row adds two reruns to the first run at 187c81e0c, which had 1,255 passed, 9 skipped and 16 setup errors. With public PyPI metadata for packaging 26.2 cached, tests/test_release_lock.py passed all 25 tests; the 16 errors came from that missing metadata. With a local-wheel manifest built from the pinned PyPI wheels, whose hashes match uv.lock, the five tests in tests/test_spm_development_authentication.py passed; they skip without a manifest.
  • Mocked HTTPX tests check the request JSON from narrate() and narrate_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.
  • Probes outside the test suite, at 229f07ff8 and 187c81e0c, called narrate() and narrate_async() with model="openai/gpt-5". LiteLLM 1.103.0 raised UnsupportedParamsError for temperature 0.0 and 0.2 before any provider POST. With parameter dropping on, direct LiteLLM calls stripped output_config with the model map bundled in the wheel, which has no Sonnet 5.5 entry. They kept it with the current public model map, which marks claude-sonnet-5-5 with supports_output_config. Narration raised ValueError for parameter dropping with both Sonnet spellings under either map, before any POST.
  • At 187c81e0c, the four remaining skips, in tests/test_be_axiom_pilot.py, need unpublished Belgium pilot source packages. The credentialed release checks need HUGGING_FACE_TOKEN and did not run locally. CI's release-input job ran them and passed at 187c81e0c.
  • At 187c81e0c, make lint passed 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 check and scripts/release_lock.py also passed. The locked Ruff 0.12.11 reports the same 11 UP038 diagnostics at 229f07ff8 and 187c81e0c.
  • No check called a live model, so no run confirmed that Sonnet 5.5 accepts the request or that 4,096 tokens leave room for text after thinking.

🤖 Generated with Claude Code

MaxGhenis and others added 3 commits October 11, 2026 22:57
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>
codex and others added 4 commits December 1, 2026 02:08
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
MaxGhenis marked this pull request as ready for review December 3, 2026 02:58
@MaxGhenis

MaxGhenis commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Merging at cb2ebc60e.

  • Independent model review (GPT-6.2 Sol on a Subfleet lane, hard tier), scoped round 4 at cb2ebc60e879f3018ba86d8626f0703a9efc17b3: VERDICT: APPROVE. It closed round 3's P1 on the temperature=None wording and both P2s (the 8,192-token wire case and the Ruff sentence), and raised no new finding.
  • CI at cb2ebc60e: all 13 checks pass, including Test on Python 3.11 to 3.14.

@MaxGhenis
MaxGhenis merged commit 5d9bb34 into main Dec 3, 2026
14 checks passed
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.

Update optional derivation narration from Claude Sonnet 4.6 to Sonnet 5.5

2 participants