Repository navigation
feat: run FAQ generation on the Claude Platform instead of OpenRouter - #387
Merged
neuromechanist merged 5 commits intoSep 17, 2026
Conversation
FAQ generation was the last server-side route to OpenRouter. It ran from the
sync scheduler (src/api/scheduler.py:240) with no caller and no BYOK key, so
the platform needed its own OPENROUTER_API_KEY for the feature to work at
all, which contradicted .env.example's claim that OpenRouter is only reached
via a caller's key or a community's openrouter_api_key_env_var.
- faq_summarizer builds both agents with create_anthropic_llm, on the
configured and the fallback path. Thinking is off for both: scoring needs
the temperature determinism it would displace, and neither agent needs
reasoning tokens across thousands of calls.
- eeglab's evaluation agent moves from qwen/qwen3-235b-a22b-2507 on
DeepInfra/FP8 to claude-haiku-4-5, the cheapest offered model. Its summary
agent stays on Haiku rather than moving up to Sonnet 5, because Sonnet
rejects `temperature` and would silently discard the 0.0/0.1 split the two
roles are built around.
- AgentConfig.provider is now inert. It still loads, so no config.yaml
breaks, and _warn_if_provider_ignored logs when one is set rather than
dropping a deliberate cost choice in silence.
- The same-model warning was inverted: with two offered models, Haiku for
both agents is the cheapest valid setup, so warning on any repeat would
fire on the recommended config. It now warns only when the evaluation
agent, the one making thousands of calls, uses the expensive model.
- summary_model_name is normalized before it is stored, so a config still
carrying a legacy id records the id that was billed and that
src/metrics/cost.py prices.
- Fixes two stale docstrings that predate the migration: default_model
("OpenRouter format", anthropic/claude-3.5-sonnet example) and
default_model_provider.
Cost note: the evaluation agent moves from a quantized open model to Haiku
at $1.00/$5.00 per 1M tokens, on the thread-scoring calls. Haiku is the
floor among offered models, so there is no cheaper option; the
quality_threshold of 0.7 still keeps ~85% of threads away from the summary
agent.
Tested: 8 new tests. The registry-wide model check fails against the
pre-migration eeglab config (ValueError on the Qwen id), and the repointed
e2e patch target fails if aimed back at create_openrouter_llm, so both are
load-bearing. Full unit suite 2090 passed, 1 pre-existing Rich-ANSI failure.
Closes #386.
The offered models, their aliases, the sampling rule and normalize_model now live in src/core/services/anthropic_models.py, which imports nothing third-party. Config validation has to resolve a model id to judge a community's choice, and it runs on CLI-only installs where langchain (and therefore anthropic_llm) is not installed. anthropic_llm re-exports the tables, so the server-side callers that have always imported them from there keep working; the split is a packaging detail, not something every router and agent should know about. Also logs, at debug, when a configured temperature is dropped and which of the two reasons applied: the model accepts only its default, or extended thinking is on. It was silently discarded before. Debug rather than warning because it is on the per-request path. Tested: new tests for accepts_temperature over every alias and offered model, that the re-exports are the same objects rather than copies, and that the drop reason is reported. Full offline suite passes.
validate_agent_roles compared agent.model against the literal string "claude-sonnet-5", so a community that wrote a legacy id such as anthropic/claude-sonnet-4.5 got no warning while still being billed for Sonnet on every thread it scored. It now normalizes first, and names both ids in the message so a maintainer recognizes the config line. Two checks added alongside it: - A model that resolves to nothing at all now warns, instead of being discovered when FAQ generation fails. - An explicitly configured temperature on a model that only accepts its default now warns that the value is dropped rather than sent. Only an explicit temperature counts; the field's own default is not a choice the community made. The same is logged once per sync run, next to the existing provider-ignored warning, since that is where an operator looks. All of these warn rather than raise: this schema backs the whole community, and a questionable FAQ setting should not stop the assistant from serving. Tested: new tests for the alias case, the unresolvable case, temperature on and behind aliases of both models, and that the field default stays silent. Also asserts CommunityConfig still imports with the server extra absent.
faq_summarizer carried its own four rate constants, left at pre-migration OpenRouter prices (Haiku 0.25/1.25, Sonnet 3.00/15.00) while the platform now bills 1.00/5.00 and 2.00/10.00. Both the estimate shown before a sync and the total reported after it were wrong, and the per-thread total was charged at Sonnet rates no matter which model actually ran. Now sourced from src/metrics/cost.py, the same table the API and CLI report from, so there is one place to update when a rate changes. Two accounting fixes fall out of it: - The scoring call is counted. It runs on every thread and is most of a run's cost, but only summarized threads were being charged for. - Each call is priced at the model that ran it, tracked through both the configured-agent and fallback paths. Estimates stay approximate in two stated directions: input tokens are derived from the thread's character count rather than counted, and fixed prompt overhead is not counted at all. The returned keys are unchanged, so the sync CLI's cost display keeps working. Tested: estimates derived from the pricing table rather than restated, that the two strategies are the models the platform offers, and that a real summarize_threads run charges for scoring alone and for both calls.
neuromechanist
merged commit Sep 17, 2026
0676926
into
feature/issue-360-epic-anthropic-platform
3 of 4 checks passed
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.
Closes #386.
Problem
FAQ generation was the last server-side route to OpenRouter.
src/knowledge/faq_summarizer.pybuilt both of its agents withcreate_openrouter_llm, whose key defaults to the platform's ownOPENROUTER_API_KEY. It is not dead code:src/api/scheduler.py:240callssummarize_threadsfrom the automated sync schedule, andsrc/cli/sync.py:861exposes it from the CLI.That contradicted
.env.example, which said OpenRouter "is only reached when a caller brings their own OpenRouter key ... or a community sets its ownopenrouter_api_key_env_var". FAQ generation was a fourth case, and the one that kept a platform-side OpenRouter key mandatory rather than optional.Change
Both agents now use
create_anthropic_llm, on the configured path and the no-config fallback. Thinking is off for both: the evaluation agent depends ontemperature: 0.0for deterministic scoring, andtemperatureis only forwarded when thinking is off; neither role needs reasoning tokens across thousands of calls.src/assistants/eeglab/config.yamlis the only community with afaq_generationblock. Its evaluation agent moves fromqwen/qwen3-235b-a22b-2507onDeepInfra/FP8toclaude-haiku-4-5. Its summary agent stays on Haiku rather than moving up to Sonnet 5, becauseclaude-sonnet-5rejectstemperature, so promoting it would silently discard the 0.0/0.1 split the two roles are built around.AgentConfig.provideris now inert; the Claude Platform has no routing layer. It still loads so noconfig.yamlbreaks, and_warn_if_provider_ignoredlogs when one is set. A community that chose FP8 quantization for cost reasons should hear that it stopped applying, not find out from a bill.The same-model warning was inverted by the migration. It fired whenever both agents named the same model and advised "use a faster/cheaper model for evaluation_agent" -- but with two offered models, Haiku for both is the cheapest valid configuration, so the warning would fire on the recommended setup. It now warns only when the evaluation agent, the one making thousands of calls, uses the expensive model.
Also fixed:
summary_model_nameis normalized before being stored, so a config still carrying a legacy id records the id that was actually billed and thatsrc/metrics/cost.pyprices; and two docstrings that predate the migration (default_modelsaid "OpenRouter format" with ananthropic/claude-3.5-sonnetexample,default_model_providerdid not say it was OpenRouter-only).Cost
The evaluation agent moves from a quantized open model to
claude-haiku-4-5at $1.00 / $5.00 per 1M tokens, and it is the agent that scores every thread. Haiku is the floor among offered models, so there is no cheaper option available; thequality_threshold: 0.7still keeps roughly 85% of threads away from the summary agent. Flagging it explicitly because it is a real increase on the highest-volume call in the pipeline, not a neutral substitution.Tests
8 new tests, no new mocks.
test_shipped_faq_configs_name_offered_claude_modelswalks the registry rather than hardcoding community names, so a community added later cannot reintroduce an unservable model. Verified load-bearing: reverting onlyeeglab/config.yamlmakes it fail withValueError: Model 'qwen/qwen3-235b-a22b-2507' is not available.test_summarizer_does_not_reach_for_the_openrouter_factoryasserts against the module source, because the import is function-local and there is no module attribute to inspect.caplogtests for_warn_if_provider_ignored, calling the real function.providerstill loads.tests/test_integration/test_mailman_e2e.pyhad its patch target repointed. Verified that target is load-bearing: aiming it back atcreate_openrouter_llmfails 2 of 4 tests (assert 0 == 1).The one failure is the pre-existing
test_version_shows_version(Rich ANSI codes), which fails on the base branch too.ruff checkandruff format --checkclean.Pre-existing issue, not fixed here
The two
test_mailman_e2e.pytests that exercise summarization driveMagicMockLLMs whose.invoke()returns canned content. That conflicts with the project's no-mocks rule, but it predates this PR and rewriting them into real paidllm-marked tests is a separate decision. This PR only repoints their patch target so they keep testing the pipeline they were written for.