Skip to content

Community-controlled reasoning effort across Anthropic, Bedrock and OpenRouter - #546

Merged
neuromechanist merged 12 commits into
developfrom
feature/issue-545-reasoning-effort
Sep 29, 2026
Merged

neuromechanist merged 12 commits into
developfrom
feature/issue-545-reasoning-effort

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Closes #545.

What

A community can set reasoning_effort in its config.yaml: one key, one scale (none, low, medium, high, xhigh, max), and every provider path turns it into that platform's own request field.
GPT-6 Luna at max made a tool-using turn take 15 to 50 s before its first word (#544 lowered it to high as a constant); this makes the level the community's to choose, on every provider and every model that has one.

Path Model Sent
Amazon Bedrock GPT-6 Luna additionalModelRequestFields: {"reasoning": {"effort": level}}
Amazon Bedrock gpt-oss-120b {"reasoning_effort": level} (low, medium, high)
Amazon Bedrock Qwen3 Next nothing (no control; a flat high hangs it)
Claude Platform on AWS Claude Sonnet 5.5 output_config.effort (low, medium, high) beside adaptive thinking; none is no up-front thinking (between_tools) at effort low
Claude Platform on AWS Claude Haiku 4.5 nothing (token-budget thinking, unchanged)
OpenRouter an offered model with levels (exactly the slugs in OPENROUTER_MODEL_IDS) body reasoning: {"effort": level} via model_kwargs; any other slug, including the older anthropic/claude-* alias slugs, is sent nothing

Rules the maintainer set, enforced in one table (REASONING_LEVELS) so they hold on every platform:

  • Each model keeps its own predetermined levels; a level it does not accept is clamped and never sent (gpt-oss cannot go below low or above high).
  • Claude Sonnet is never run above high, whatever a community asks.
  • Unset, a model runs at its own default on every provider: high for Luna and gpt-oss; nothing for Sonnet, so the Claude Platform's own default applies as before.
  • A level the community's own default_model cannot honor is a warning at load, not an error (the key applies to every model a request can run).
  • NWB and NEMAR set high explicitly.

OpenRouter does not let a request turn off the reasoning of the models it marks mandatory (Sonnet, gpt-oss), so none is raised to their lowest level there.

Behavior change to look at: OpenRouter's own default effort for Luna and gpt-oss-120b is medium; with no community key OSA now sends high on OpenRouter as on every provider, so a caller with their own OpenRouter key gets more reasoning, and a longer wait, on those two models than before (disclosed in the CHANGELOG under Changed and in ADR 0015).

Measured

Through the real NWB graph on a documentation question, Luna's median time to first text (3 runs per level): none 2.5 s, low 2.8 s, medium 5.2 s, high 5.2 s, xhigh 10.6 s, max 48 s.
At xhigh and max it also skipped the documentation search in the median run, so the answer had no citations; the config comment says so.
Bedrock's accepted levels and the wrong-shape traps (nested field is a 200 no-op for gpt-oss, flat is a 400 for Luna) were measured against the live service.

Not verified by a request

There is no Anthropic or OpenRouter key on the development machine.
For those two paths the tests read the request the real client builds (the ChatAnthropic payload; the body LiteLLM posts to a local fake of OpenRouter's endpoint).
The independent review checked the field names, levels and constraints (output_config.effort, between_tools at effort high or below, OpenRouter's reasoning.effort and its mandatory-reasoning models) against Anthropic's and OpenRouter's current documentation and OpenRouter's public models listing on 2026-09-29; no request was sent.
The first request through a real key is still the check that is left: pytest tests/test_integration/test_anthropic_platform.py -m llm.

Tests

  • tests/test_core/test_reasoning_effort.py: scale, per-model levels (a pinned result for every level of every model, written out), clamp (including a gap in a model's levels), provider-aware levels, defaults, the config field and its warnings (including a default_model named by an alias, and a typo).
  • tests/test_core/test_reasoning_effort_providers.py: the request each provider puts on the wire, per model and level, with the wrong-shape guards; OpenRouter slug handling (offered slugs, older alias slugs, an unmapped slug not read as the default model, the debug line); caching on and off; every model with levels has a path that sends them.
  • tests/test_api/test_reasoning_effort_routing.py: through the real create_community_assistant, the community's level reaches the model each path builds, for the shipped NWB and NEMAR YAML and dynamically for every community that sets a level.
  • tests/test_cli/test_validate.py: osa validate lists the load-time warning in its Warnings block.
  • Each rule was mutation-checked (25 mutations across the tables, the three factories, the router call sites, the validator and osa validate); all are killed.
  • Full offline suite (3,600 tests) and ruff pass.

Review

An independent Sonnet review found no critical issue and two important ones, both on the OpenRouter path (an unmapped slug read as the default model; alias slugs read as the offered Sonnet), plus suggestions.
All are addressed except one intentional choice: Claude Haiku 4.5, the default of most communities, ignores the key (its thinking is a token budget, not a level); the ADR says so and the config load warns.
osa validate now lists the schema's load warnings, and Sonnet's none is no up-front thinking at effort low rather than the API's default effort.

Docs

ADR 0015, an ADR 0014 pointer, .context/yaml_registry.md, CHANGELOG.
The schema reference on docs.osc.earth lives in osc-docs and is not changed here.

  • Tests
  • Ruff
  • Live Anthropic and OpenRouter requests

Refs #545. One neutral scale (none, low, medium, high, xhigh, max), each
model's accepted levels in one table (Luna none to max, gpt-oss low to high,
Claude Sonnet none to high and never above, Haiku and Qwen none), a clamp that
sends a model only a level it accepts, and CommunityConfig.reasoning_effort
with a load-time warning when the default model cannot honor it. Not wired to a
provider yet. 80 tests read the real tables; letting Sonnet through at max
fails 3 of them.
…to Bedrock

OpenRouter cannot turn reasoning off for the models it makes mandatory, so
none is not a level there. A model's own default now applies on every
provider. Bedrock models name their request field (nested for Luna, flat for
gpt-oss, none for Qwen) instead of carrying a fixed effort.

Tested: unit tests for levels, clamp (including a gap), defaults; Bedrock wire
tests follow in a later commit.
Claude Platform: output_config.effort beside adaptive thinking; none turns
thinking off. OpenRouter: the unified reasoning.effort body field through
model_kwargs, since LiteLLM's own reasoning_effort has no max and raises for
models its map does not list.

Tested: request-shape tests follow in a later commit.
Tested: routing tests follow in a later commit.
Bedrock: the Converse body botocore would send. Claude Platform: the payload
ChatAnthropic builds. OpenRouter: the body LiteLLM posts to a local fake.
Router: the community's level reaches the model each path builds.

Tested: 121 new tests; each rule mutation-checked.
Both default to Luna, where max took 15 to 50 s to a first word and xhigh
often skipped the documentation search.

Tested: configs load; level is high.
…ffort low on Sonnet

Review findings on #546:
- An unmapped OpenRouter slug was read as normalize_model(None), the default
  model; effective_reasoning_effort now refuses a missing model.
- The reverse map no longer follows normalize_model aliases: an older
  anthropic/claude-* slug runs as the older model on OpenRouter, so the offered
  Sonnet's levels say nothing about it. A debug line says when a level is dropped.
- Sonnet none is no up-front thinking at effort low (no level is lower), not
  thinking off with the API's default effort.
- REASONING_SCALE is derived from the ReasoningEffort Literal.
- Stale comments corrected; measurement wording narrowed.

Tested: slug, alias, patched-default, log, caching-off and parity tests; 11
mutations killed.
…arnings in osa validate

The warning skipped every default_model containing a slash, including aliases
that resolve to Sonnet on the Claude path and clamp there; it now resolves
through normalize_model first and skips only an unknown model, which removes a
second, misleading warning for a typo. osa validate now collects the schema's
UserWarnings into its Warnings block instead of leaving them on stderr.

Tested: alias, typo and pinned per-level tests; validate lists the warning.
…nity runs

Tested: routing tests load the real YAML; a dynamic test covers every community
that sets a level.
…in the docs

OpenRouter's own default for Luna and gpt-oss is medium; OSA sends high. Also
notes prompt-cache invalidation on a level change and that Haiku ignores the key.

Tested: not applicable (docs).
Building the NEMAR assistant discovers its MCP tools from mcp.nemar.org, so the
shipped-YAML and dynamic routing tests made the offline suite depend on a live
service (up to 25 s per discovery). They now build the assistants without MCP
servers; which tools a community has is not what they test.

Tested: routing tests pass in 1.8 s with all HTTPS sent to a dead proxy and no
MCP log lines; the previous version logged MCP discovery failures there.
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