Repository navigation
Fix release review findings: per-model notes, Bedrock fallback logging and reporting, tests - #565
Merged
Merged
Conversation
OPENROUTER_MODEL_IDS, OPENROUTER_ROUTING_VARIANTS and openrouter_model_id move to anthropic_models.py, which has no third-party imports, so community config validation can use them on a CLI-only install. litellm_llm re-exports them. No behavior change. Tested: litellm and reasoning-effort unit tests.
provider='bedrock' with a key, or with a key source other than 'platform', is refused at construction. A byok Bedrock choice would spend the platform's Bedrock token while _check_model_cost skips byok requests entirely. Tested: test_bedrock_routing.py.
The notes and a community's model_instructions are keyed by offered id, but the OpenRouter path passed the provider's slug (openai/gpt-6-luna), so both missed. _route_request now computes the offered id once and RequestRoute carries it; create_community_assistant passes that as model_id. RequestRoute also refuses contradictory parts: a provider_hint off OpenRouter, a Bedrock model off the bedrock provider (or the reverse), and an offered id that is not the one the model stands for. Tested: new test_request_route.py (HED, BYOK OpenRouter and platform paths); the notes tests fail without the fix.
normalize_model reads an empty id as the default model, so a key of '' filed the text under Haiku without a word. A falsy or blank key is now a config error. Tested: test_community.py (blank keys).
…a Bedrock default does A default_model of openai/gpt-oss-120b (an offered model's OpenRouter slug) loaded silently and answered 400 on the Anthropic and Bedrock path; it now warns and names the id to write. The Bedrock-default warning lists what each key combination does (Claude fallback, OpenRouter, HTTP 500) instead of 'the Claude default' alone, and names OFFERED_MODELS where it is defined. Tested: test_community.py (slug warnings, warning text).
The fallback to Claude logged ERROR on every BYOK and CLI request, which are expected, and twice per /chat/resume, burying the real misconfiguration. It is now ERROR only when the deployment lacks the Bedrock key, WARNING when the caller's own key is the cause, and /chat/resume's route probe does not log. The fallback record carries community_id, model, fallback, key_source, cause. The HTTP 500 for a deployment with no platform key is now logged at its raise site with the community id, and says a Bedrock key alone serves nothing. Tested: test_bedrock_routing.py (levels, extra fields, every shipped Bedrock community without a Bedrock key, no-key 500, OpenRouter-only fallback).
GET /{community}/ reported the community's Bedrock default_model even on a
deployment that cannot run it (and omits it from offered_models), so the widget
showed 'Community default: GPT-6 Luna' while the server ran the Claude fallback.
It now reports what a platform request runs: the Claude fallback when Bedrock
cannot be served, the model itself when OpenRouter runs it (no Anthropic key).
At startup the app logs one record per shipped community whose Bedrock default
cannot be served: ERROR when requests run Claude or fail, WARNING when OpenRouter
runs it, each naming AWS_BEARER_TOKEN_BEDROCK and ANTHROPIC_API_KEY.
Tested: new test_bedrock_deployments.py over eight key combinations, the real
registry and routers, and the app lifespan; tests/helpers/deployment.py shares
the key setup with test_bedrock_routing.py.
…MODELS REASONING_LEVELS, REASONING_SCALE and DEFAULT_REASONING_EFFORT are typed with ReasoningEffort, and resolve_reasoning_effort and friends return it. The provider Literal was spelled three times; ProviderName in anthropic_models.py is the one spelling (it replaces ReasoningProvider). SAMPLING_MODELS is a frozenset. No behavior change. Tested: core and routing suites; ruff.
Haiku has reasoning levels; Bedrock waits at high effort or above, not only maximum; the Luna registry id is served through the us. profile at a 10% premium over the global rate OpenRouter matches; OFFERED_MODELS is defined in anthropic_models, not anthropic_llm; _warn_retired_env_vars reads os.environ only. CACHEABLE_MODELS and is_cacheable_model claimed caching for all models, contradict takes_cache_markers and are referenced nowhere, so they are deleted. No behavior change. Tested: litellm unit tests; ruff.
… handling NEMAR is routed through the real code (Claude Platform, Sonnet, native blocks, effort high). The Luna test derives its communities from the registry. The dynamic level test handles Haiku's thinking budget as well as Sonnet's output_config, and a new rule keeps communities with client tools or MCP servers off Bedrock defaults (their figures need image blocks). Tested: this file.
…efault An OpenRouter-only deployment runs hed and nwb as openai/gpt-6-luna and nemar as anthropic/claude-sonnet-5.5 through real model construction. /chat/resume with no model on a Bedrock-default community is driven through the real endpoint with real routing at both call sites: one fallback log, and the image decision agrees with the model that runs. Tested: these files.
… set The test set no keys, so the menu left the Bedrock ids out and the loop skipped them silently. It now sets the keys and asserts they were checked. Tested: test_community_router.py.
Four times the whitespace must cost under eight times as much: linear reading passes at about four, quadratic reading shows about sixteen. Best of three runs each. Tested: passes; a quadratic pattern fails it.
FakeOpenRouter is a context manager, switches garbage collection off only after the server is up, and restores it even if stopping the server raises. The three fixtures use it, so a failing setup or teardown cannot leave collection off or the server running. Tested: the fixtures' suites and new cases in test_fake_openrouter_gc.py.
This was referenced Sep 30, 2026
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 the findings of the five-reviewer review of release PR #562 (develop -> main). Each was reproduced or confirmed against the code first.
Changes
_route_requestcomputes the offered model id once (_offered_model_id) andRequestRoute.offered_model_idcarries it;create_community_assistantpasses it asmodel_id. Before, the OpenRouter slug (openai/gpt-6-luna) found neither the built-in anti-search-loop note nor a communitymodel_instructionsentry (Claude slugs included). Confirmed by failing tests on the old line (9 failures).RequestRouteinvariants.__post_init__refuses aprovider_hintoff OpenRouter, a Bedrock model off thebedrockprovider (or the reverse), and an offered id that is not the one the model stands for.ProviderChoice.provider="bedrock"requiresapi_key=Noneandkey_source="platform";ProviderChoice("bedrock", "sk-user", "byok")now raises.model_instructionsblank key is a config error (an empty key normalized to Haiku).default_model: openai/gpt-oss-120b(an offered model's OpenRouter slug, or that slug with a routing variant) now warns at load and names the id to write. The slug table moved toanthropic_models.py(no third-party imports) so config validation can use it on a CLI-only install;litellm_llmre-exports it.GET /{community}/reports what a platform request runs: the Claude fallback (and the platform's routing hint) when Bedrock cannot be served or nothing can run the model, the community's own default when Bedrock serves it or OpenRouter runs it (no Anthropic key: the model runs under its slug)./chat/resume's route probe no longer logs (log_fallback=False), so a request logs once. Record fields:community_id,model,fallback,key_source,cause.log_unserved_bedrock_defaultsruns in the app lifespan: one record per community whose default is a Bedrock model the deployment cannot serve, each namingAWS_BEARER_TOKEN_BEDROCKandANTHROPIC_API_KEY. ERROR when requests run Claude or fail with 500; WARNING when OpenRouter runs the model (see 9).REASONING_LEVELS,REASONING_SCALE,DEFAULT_REASONING_EFFORTtyped withReasoningEffort; return types follow. OneProviderNamealias replaces the three spellings (ReasoningProvideris gone).SAMPLING_MODELSis a frozenset.cost.pynames theus.profile premium;OFFERED_MODELSpoints atanthropic_models;_warn_retired_env_varsdocuments that it readsos.environonly; the stray dash is gone;CACHEABLE_MODELSandis_cacheable_model(unreferenced, contradictedtakes_cache_markers) are deleted./chat/resumewith a Bedrock default (real routing at both call sites, provider factories scripted); (f) offered-models test sets the keys; (g) timing test compares scaling; (h) loopback server fixtures are context managers with robust teardown.Not changed
_platform_choicefallback for a deployment with no Anthropic key (it warns on every such request), and_serves_bedrock_modelshiding the Bedrock models from the menu there is deliberate and tested (Bedrock is reached only from the Anthropic provider). ADR 0004 calls OpenRouter retired as a platform route; the fallback is the documented exception in code, and the ADR 0014 text does not cover this combination. Behavior kept; the new startup WARNING and the corrected load-time text make it visible.boto3/botocorefloor. The Dockerfile (uv sync --frozen --no-dev --extra server) and every CI job (uv sync --frozen) install fromuv.lock, which pinsboto3andbotocore1.43.104. No floor added.src/assistants/hed/config.yamlandbids/config.yamlcomments still sayanthropic_llm.OFFERED_MODELS; those files are owned elsewhere.Tested
uv run ruff check . && uv run ruff format --check .uv run pytest --ignore=tests/test_integration -m "not integration and not llm and not network" -q -p no:cacheprovider --color=no: 4046 passed, 14 skipped, 75 deselected (ruff clean).