One provider resolver for LLM calls, a record of what each call sends, and no OpenAI key sent to OpenRouter - #28
Merged
Conversation
…, and no OpenAI key sent to OpenRouter The provider switch was read at four routing sites, and about thirty call sites each spelled out the same Azure-or-not branch. This change makes digdir.llm.provider the only reader, and records enough to show that behaviour is unchanged before and after. - Tests pin today's provider selectors, the reads of the provider switch, step parameters and the boot-required environment, so each later change flips exactly the pins it names. - The graph runner records which layer set each step parameter, and each LLM call records what it sent: branch, endpoint host, whether a key was present and where it came from (never its value), and the model and sampling parameters as passed and as sent. The record is reported to an enclosing sink only; nothing is added to returned results, which reach MCP clients. - The OpenAI-compatible key is never sent to openrouter.ai. Both OpenRouter paths used to fall back to OPENAI_API_KEY when services.openrouter.api-key was unset; they now refuse, naming the path, for an unset or blank key. - services.openrouter.model is registered, so the :openrouter search-phrases arm resolves instead of throwing. - services.llm.provider, services.llm.api-endpoint and services.llm.api-key are defined. Nothing reads them yet; the environment rows stay on the environment until their reader lands, so verification and the runtime never disagree. - digdir.llm.provider: one read of the switch (unset means not Azure, decided once), resolve for the complete call spec, and model-for for a site that picks its model in one place and calls in another. Every call site passes the spec to the client unchanged. - Langfuse tracing (Digdir #13) resolves the configured model through provider/model-for: the same value, without a second read of the switch. - A test-only capture compares the resolved parameters of every LLM-calling entry point across a configuration matrix, so a later change that alters behaviour has to declare it. A second census needle covers services.llm.provider.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Summary
The provider switch (
services.azure-openai.use-azure-openai-api) was read at four routing sites, and about thirty callsites each spelled out the same Azure-or-not branch. This PR makes
digdir.llm.providerthe only reader of that switch. Italso adds the instrumentation and the tests that show the behaviour is unchanged, and closes a key leak to OpenRouter.
This is the first of two PRs on LLM provider selection; the second reads
services.llm.*.What changes
Pins of today's behaviour (tests only):
Later changes flip exactly the pins they name.
A record of what each LLM call sends. The graph runner records which layer set each step parameter. Each call
records:
The record is reported to an enclosing sink only. Nothing is added to returned results, which reach MCP clients.
No OpenAI-compatible key is sent to openrouter.ai. Both OpenRouter paths used to fall back to
OPENAI_API_KEYwhenservices.openrouter.api-keywas unset. They now refuse for an unset or blank key, naming the path.services.openrouter.modelis registered, so the:openroutersearch-phrases arm resolves instead of throwing.services.llm.provider,services.llm.api-endpointandservices.llm.api-keyare defined.disagree.
digdir.llm.provider:resolve, for the complete call spec;model-for, for a site that picks its model in one place and calls in another.Every call site passes the spec to the client unchanged.
A test-only capture compares the resolved parameters of every LLM-calling entry point across a configuration
matrix. A later change that alters behaviour has to declare it. The capture lives in
server/test/fixtures/provider-capture/.Effect on Digdir #13 (Langfuse tracing)
Digdir #13 read the run's configured model through
cfg/use-azure-openai?, which this PR removes. It now usesprovider/model-for: the same value, the provider's default model for the tenant, without a second read of the switch.Testing
bb teston this commit: 2520 tests, 11344 assertions, 0 failures. There are 8 errors, all in tests that need a network service the test environment does not provide (Net.java), and they are the same 8 as on the base branch.bb lint: 0 errors, 0 warnings.