Skip to content

Tagged citations, cache markers and usage for the OpenRouter path; send each call's own key - #528

Merged
neuromechanist merged 82 commits into
developfrom
feature/issue-526-openrouter-tagged-citations
Sep 29, 2026
Merged

neuromechanist merged 82 commits into
developfrom
feature/issue-526-openrouter-tagged-citations

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Closes #526. Stacked on #527 (the Bedrock models); the base is that branch. Retarget to develop after #527 lands.

What this does

A request funded by an OpenRouter key (a caller's own, or a community's) now gets the same numbered [n] markers and source list as Claude, through the tagged-source layer the Bedrock models use, instead of the prompt-only "end the sentence with a markdown link" rule. It applies to every OpenRouter model, Claude slugs included.

CachingLLMWrapper (a BaseChatModel that held a ChatLiteLLM and forwarded to it) is replaced by TaggedCitationChatLiteLLM, a ChatLiteLLM subclass (src/core/services/litellm_chat.py): bind_tools and streaming are native, and three things happen at the model boundary:

  • Cache breakpoints on the system prompt and the last message, as before, now only for Anthropic slugs (LiteLLM dropped the marker for the others but left the message reshaped into a one-part list).
  • Tagged citations: search_result tool content becomes [src:N] text, and the model's tags come back as the citations the Anthropic path produces. ChunkRetagger (shared with the Bedrock model) does the streaming half.
  • Usage: the provider's own usage (cache reads and writes, reasoning tokens) reaches usage_metadata, where the metrics price it.

A security fix found on the way

LiteLLM keeps API keys on the litellm module, which every request in the process shares, and does not send them with the call. Requests running at the same time under different keys (a caller's own key next to the platform's) went out under whichever key was written last: 20 of 40 interleaved requests used the other key in a local measurement, and on the old code all requests of a thread stress used one key. The key now travels with each call, nothing is written to the module, and a model with no key refuses instead of borrowing one. Regression tests (async, and from threads, which is how the agent's model node calls it) fail without the change. This affects production today for OpenRouter bring-your-own-key and community-key requests; the change is in its own commits (Send the OpenRouter key with each call and Build OpenRouter request parameters without LiteLLM's shared module) if you want it earlier than the rest.

Review

An independent review of this branch found no critical defect and these, all addressed with a test that fails without the change:

  • Usage was inert against the real service. OpenRouter documents its usage as a chunk that repeats finish_reason after the real one; LiteLLM's stream wrapper emits its own final usage chunk at the first finish and never uses the provider's, so a reply reported a local estimate (input 8, output 1 for a 100-token prompt) with no cache or reasoning counts. A tap beneath the wrapper now reads the provider's usage (sync and async, three chunk shapes, and the no-usage case).
  • The caller's key was logged by LiteLLM at DEBUG (the arguments of each call): its loggers are held at WARNING, with a test.
  • A tool result's documents were joined with no separator (a source header ran on from the previous reminder): blank line between them.
  • invoke(stream=False) on a streaming model sent stream: true and crashed (also true of the old wrapper).
  • Cache markers reshaped messages for models that cannot use them: Anthropic slugs only.
  • Module-global residue of the caller's key on litellm: no longer written.
  • Test gaps (held-back tail of a stream, async complete reply, the stream branch of _generate/_agenerate, concurrent sync requests) and the fake server's request/header pairing.
  • Stale documentation (CitationInfo in the OpenAPI schema, docstrings, a widget comment, routing notes).

Not verified

There is no OpenRouter key on the development machine, so nothing here ran against the real service. Everything above is tested against a local fake that speaks OpenRouter's chat-completions wire format through the real LiteLLM and OpenAI client stack. tests/test_integration/test_openrouter_citations.py (11 tests, skipped without OPENROUTER_API_KEY_FOR_TESTING) is written for the real service and should be run before relying on the cost figures: it asserts the tool loop is accepted with tagged text and cache markers, no tag reaches the reader on a complete or streamed reply, a repeated Anthropic prefix reports cache reads, and a reasoning model reports reasoning tokens. The usage tap depends on LiteLLM's completion_stream attribute (pinned by the lock; the tests fail if it moves).

Separately observed, not caused by this change: when many threads reach a cold LiteLLM at once they race to build its HTTP client and one can see Bad file descriptor; a first burst after a restart on the OpenRouter path could hit it.

Testing

REQUIRE_API_AUTH=false uv run pytest tests --ignore=tests/test_integration -m "not network" passes (3,245 tests before the review fixes, more after); ruff clean; ty reports nothing new.

Sonnet 5.5 (claude-sonnet-5-5) costs the same as Sonnet 5. Earlier Sonnet
ids keep resolving, now to the new model, so saved widget settings and
community configs continue to work.

Sonnet 5.5 rejects thinking type "disabled" with a 400, so thinking=None
sends "between_tools" (its lowest setting) instead. The FAQ summarizer is
the caller that turns thinking off.

Unit tests pass. The live endpoint check (test_thinking_off_is_accepted)
was not run: the platform key is not configured locally.
The NEMAR assistant answers noticeably better on Sonnet than on Haiku.
Sonnet 5.5 costs about twice Haiku 4.5 per token ($2 / $10 versus $1 / $5
per 1M input / output tokens), so NEMAR requests get more expensive.

Community config validation passes in the full suite.
Sonnet 5 onward bills a full-size image at up to about 4784 tokens, not the
1568 of the standard tier, so the flat 1600 under-counted every NEMAR figure
by up to 3x and delayed trimming. Haiku's images are now over-counted, which
only spends headroom.

Image-budget tests pass; they use the constant, not its value.
Thinking blocks can arrive in a list-shaped reply even with extended
thinking off, and .strip() on a list raises. The FAQ scorer and summarizer
now take the text from the reply the way the rest of the code does.
The backend still resolves the retired id, but the settings dropdown lists
only offered models, so a saved claude-sonnet-5 showed as a custom model.
A drift test keeps the widget's map equal to the backend's aliases.
The payload for thinking=None on Sonnet 5.5 is asserted directly: between_tools,
and none of the parameters the model rejects.
The API key was the first field, with no model to use it for; the model menu
was below it. The model menu now comes first, and the model name and the
API key appear only when Custom is chosen, since they exist for a model the
community does not offer, paid for by the reader's own key. A key that is
already saved stays in view so it can be seen and removed, a custom model
cannot be saved without one, and a key the dialog is not showing is not saved.

26 checks in a happy-dom window (frontend/test-widget-settings.js, added to CI);
the other widget suites still pass.
tests.yml gates branch protection and test.yml runs on main; the two copies of the
frontend job must list the same steps, and tests/test_frontend_job_parity.py fails
when they do not. The Settings suite was added to tests.yml alone.
ChatBedrockConverse is the client for the Bedrock models (GPT-6 Luna,
Qwen3 Next, gpt-oss-120b): one Converse transport for all three, with
tool calls, streaming, and cache token accounting mapped to usage metadata.
It brings boto3 and botocore.
AWS_BEARER_TOKEN_BEDROCK (or BEDROCK_API_KEY) pays for the Bedrock models;
BEDROCK_REGION defaults to us-east-2, the Ohio region the Claude Platform on
AWS endpoint already uses.
The three Amazon Bedrock models are offered next to the Claude ones: ids,
labels, the Converse invoke id and Region for each, reasoning settings, and a
prompt note for the two that search in a loop. Pricing follows the Bedrock
model cards and price list; a test keeps every Bedrock model at or below
Claude Haiku 4.5. OpenRouter slugs are added for callers with their own key,
and the widget fallback list gains the three entries.

Luna rejects temperature, so it is outside SAMPLING_MODELS. FAQ generation
stays Claude-only: create_anthropic_llm refuses a Bedrock id and the config
validator warns.

The Bedrock client and the routing come in the next commits; until then a
request that names one of these models fails. Unit tests pass.
Bedrock's GPT-6 Luna, Qwen3 Next and gpt-oss-120b reject search_result
blocks, so the numbered [n] citations the widget shows would not work for
them. This module gives them the same result by convention: tool results
are tagged [src:N] on the way out, the model writes the tag after each claim,
and the tags are cut from the reply and returned as citations in the shape
the Anthropic path produces. CitationAssembler and the SSE events run
unchanged; a test pushes the output through the real assembler and checks
streamed and complete replies agree.

A tag naming no source is dropped, never shown. cited_text is the closest
passage of the source, not a provider-verified span. Nothing calls this yet.
Unit tests pass.
create_bedrock_llm builds GPT-6 Luna, Qwen3 Next and gpt-oss-120b as one
Converse transport, on the platform's Bedrock API key, with the tagged-source
citation convention applied at the model boundary (TaggedCitationChatBedrock).

The boto clients are built here instead of by langchain-aws: its api_key path
still walks botocore's ambient credential chain first, which on a machine whose
default profile is an 'aws login' session fails asking for botocore[crt]. The
key lives in the client's own token chain and never touches os.environ.

Checked live against Bedrock: streamed and complete replies carry citations
for all three models; Luna's automatic cache writes then reads (10,855 tokens)
show up in usage_metadata input_token_details, where the metrics read them.
Offline tests use botocore's before-send hook and hand-built event-stream
frames, so the request, bearer header and reply parsing are the real ones.
Unit tests pass.
Every turn of a tool loop sends the earlier turns back. GPT-6 Luna answers
400 to reasoning text in an assistant turn, and gpt-oss-120b and Qwen3 Next
to its signature (tested live), so the second model call of any conversation
that used a tool would have failed. Reasoning blocks are now dropped before
a Bedrock request.

A chat can also switch models between requests. A Bedrock turn replayed to
Claude carried an unknown reasoning_content block and citations indexed
against tagged sources; only its text and tool calls go to Anthropic now.
Unit tests pass.
A model can need telling things another does not: GPT-6 Luna at maximum
effort and gpt-oss-120b keep searching with reworded queries until they run
out of tokens, unless asked to answer after a couple of searches (tested
live; Claude and Qwen3 Next did not need it). The platform adds that note
for those two, and a community can add its own per model with the new
model_instructions config section, applied after the built-in note and only
on requests that run that model.

Keys must resolve to an offered model; a typo is an error, not a silent no-op.
The assistant also learns to ask for [src:N] tags when citations are tagged.
Unit tests pass.
A request that names a Bedrock model, or whose community defaults to one, runs
on the platform's Bedrock key whichever key would otherwise have paid. A
caller's own Anthropic key cannot select one: BYOK skips the origin check
because it pays for itself, and the platform pays for Bedrock. A deployment
with no Bedrock key answers 400 and leaves the models out of the widget menu.
An OpenRouter-key caller gets the same model's OpenRouter slug.

Bedrock requests use tagged citations, so tools return search_result blocks
as on the Anthropic path; images stay Anthropic-only. /chat/resume decides
its images from the same routing as the chat request.
Unit tests pass.
GPT-6 Luna and gpt-oss-120b return their reasoning as reasoning_content
blocks. The classifier logged an 'unrecognized content block' warning for
every model call, and the widget's Thinking indicator never fired. They are
now classified like Claude's thinking blocks: a content-free signal.
Unit tests pass.
Through the full stack on three HED documentation questions, Qwen3 Next tagged
its answer in 5 of 7 runs with only the system-prompt instruction, and in 12
of 13 with a one-line reminder after the source text; GPT-6 Luna and
gpt-oss-120b tagged 9 of 9 either way. The instruction now also says it
replaces the prompt's earlier 'include links' guidance, which Qwen followed
instead. Unit tests pass.
Against the real service, for each model: a short answer, a second model call
in a tool loop (the one that failed when reasoning was replayed), and a reply
that never shows a citation tag and cites only sources that were in the
conversation. For GPT-6 Luna: a repeated prompt prefix is read back from cache.
Model wording is never asserted on. Run: 10 passed (skipped without a Bedrock
key).
ADR 0014 records the decision, what calling the three models showed, and the
consequences; 0004 and the ADR index point to it. The Dockerfile's variable
list and .context/api-structure.md describe AWS_BEARER_TOKEN_BEDROCK and the
routing.
… stall the server

MARKER_PATTERN began with an unbounded run of horizontal whitespace, so re.search
retried from every position inside a run: quadratic in the run's length, and a
held run was rescanned on every streamed chunk. 50,000 spaces took 2.3 s to read
in one go and 41 s streamed at 12,800 (re holds the GIL, so every other request
waited too). A tag now takes at most 64 characters of whitespace before it, and
no more than that is held back while streaming; a longer run is released as text.
Streaming and one-shot reading still agree at any chunking, tested with runs
longer than the bound. Regression test fails on the old pattern (2.3 s).
The [src:N] header, the Source line and the closing reminder were plain text in
the same channel as the document, so a forum post containing a fake header
('[src:1] HED specification' on its own line, then a Source line) looked like a
real one and the model could cite the post under the specification's tag; the
reader would see the authoritative source with a real quote from it. Native
search_result blocks cannot be forged that way because their boundaries are
structural.

Text that reads like a tag ([src:N] in ASCII or fullwidth brackets, with the
spacing variants the parser accepts) is now written as (src:N) before it is shown
to the model, and the title and source are put on one line so they cannot start a
second header. The source list still quotes the document's own words. Tests are
adversarial (forged header, forged reminder, title and source with newlines,
fullwidth brackets) and fail without the change.
A text block split into cited segments took indexes 0..k, which collide with the
provider's own blocks after it: Qwen3 Next has no reasoning block, so its tool-use
block sits at index 1, and the second cited segment's block absorbed the tool
call's id, name and input when the streamed chunks were added together. tool_calls
stayed correct, but the stored content was corrupt. Segment indexes now start at
1,000,000, above any position a provider assigns. The test merges a cited text
block and a tool-use block and fails on the old indexes.
_select_model's provider annotation now includes 'bedrock' (a Bedrock provider
resolves its model the way Anthropic's does), and the search_result and cited-text
checks are TypeGuards so the block they test is narrowed to a dict where it is
used. No behavior change; ty reports nothing new against develop's baseline of
pre-existing diagnostics in these files.
_bedrock_choice refuses a caller's own Anthropic key and a deployment without a
Bedrock key. Applied to a community whose default_model is a Bedrock model (the
issue 514 case), that refused every request that named no model: the CLI, which
never sends one and can only use its own key, got a 403 telling it to remove its
key, and a deployment without AWS_BEARER_TOKEN_BEDROCK got a 400 for the whole
community. When nobody asked for the model, the request now runs the deployment's
Claude default (else Haiku 4.5) and logs an error naming the community. A caller
who names the Bedrock model still gets the refusal. Six routing tests.
…:variant ids

The warning says what a Bedrock default costs the callers who cannot have it (own
key with no model named, deployment without a Bedrock key) so it is seen at load
time, not in a log after the fact. The model-id pattern now allows a trailing
:variant, so Bedrock's own invoke id for gpt-oss-120b (openai.gpt-oss-120b-1:0),
already an accepted alias in requests and model_instructions, is accepted as a
default_model too; OpenRouter slugs such as ':free' benefit as well.
…ne at load

- The log formatter redacts Amazon Bedrock keys (long-term ABSK..., short-term
  bedrock-api-key-...) and any bearer credential in an Authorization header dump;
  botocore logs the whole request, header included, at DEBUG, and the raw key
  appeared in the output. The botocore logger is held at WARNING so the dump is
  not produced at all, since a record that reaches a handler other than ours (a
  tracing or error-reporting integration) is not redacted.
- Settings trims the key, treats a blank one as unset, and refuses one with
  whitespace inside. A trailing newline or CRLF made the HTTP client refuse the
  Authorization header, and its error names the header value, key included.
  Settings no longer echoes an input in a validation error
  (hide_input_in_errors), so a rejected key is not printed to the startup log.
Tests cover each format, the botocore dump line, the logger levels, and the
cleaning rules.
OSA prices ordinary = input_tokens - cache_read - cache_creation, which is right
only if input_tokens is the whole prompt. Measured against Bedrock: inputTokens is
the uncached remainder (2 of 9,216 on a repeated prompt) and langchain-aws adds the
cache read and write counts back, so the arithmetic holds; the test now says so
against the real service instead of only checking the library's addition.
The endpoint decides whether run 2 carries a result's images by asking the routing
that will run the model. Nothing covered a Bedrock model there. The synthetic
community now has an allowed origin, so a platform-funded request can resolve: a
Claude model on the platform key sends the image (the control), a Bedrock model
sends the placeholder. Fails if takes_native_blocks is wrongly true for Bedrock.
A model can need telling things another does not: GPT-6 Luna at maximum
effort and gpt-oss-120b keep searching with reworded queries until they run
out of tokens, unless asked to answer after a couple of searches (tested
live; Claude and Qwen3 Next did not need it). The platform adds that note
for those two, and a community can add its own per model with the new
model_instructions config section, applied after the built-in note and only
on requests that run that model.

Keys must resolve to an offered model; a typo is an error, not a silent no-op.
The assistant also learns to ask for [src:N] tags when citations are tagged.
Unit tests pass.
A request that names a Bedrock model, or whose community defaults to one, runs
on the platform's Bedrock key whichever key would otherwise have paid. A
caller's own Anthropic key cannot select one: BYOK skips the origin check
because it pays for itself, and the platform pays for Bedrock. A deployment
with no Bedrock key answers 400 and leaves the models out of the widget menu.
An OpenRouter-key caller gets the same model's OpenRouter slug.

Bedrock requests use tagged citations, so tools return search_result blocks
as on the Anthropic path; images stay Anthropic-only. /chat/resume decides
its images from the same routing as the chat request.
Unit tests pass.
GPT-6 Luna and gpt-oss-120b return their reasoning as reasoning_content
blocks. The classifier logged an 'unrecognized content block' warning for
every model call, and the widget's Thinking indicator never fired. They are
now classified like Claude's thinking blocks: a content-free signal.
Unit tests pass.
Through the full stack on three HED documentation questions, Qwen3 Next tagged
its answer in 5 of 7 runs with only the system-prompt instruction, and in 12
of 13 with a one-line reminder after the source text; GPT-6 Luna and
gpt-oss-120b tagged 9 of 9 either way. The instruction now also says it
replaces the prompt's earlier 'include links' guidance, which Qwen followed
instead. Unit tests pass.
Against the real service, for each model: a short answer, a second model call
in a tool loop (the one that failed when reasoning was replayed), and a reply
that never shows a citation tag and cites only sources that were in the
conversation. For GPT-6 Luna: a repeated prompt prefix is read back from cache.
Model wording is never asserted on. Run: 10 passed (skipped without a Bedrock
key).
ADR 0014 records the decision, what calling the three models showed, and the
consequences; 0004 and the ADR index point to it. The Dockerfile's variable
list and .context/api-structure.md describe AWS_BEARER_TOKEN_BEDROCK and the
routing.
… stall the server

MARKER_PATTERN began with an unbounded run of horizontal whitespace, so re.search
retried from every position inside a run: quadratic in the run's length, and a
held run was rescanned on every streamed chunk. 50,000 spaces took 2.3 s to read
in one go and 41 s streamed at 12,800 (re holds the GIL, so every other request
waited too). A tag now takes at most 64 characters of whitespace before it, and
no more than that is held back while streaming; a longer run is released as text.
Streaming and one-shot reading still agree at any chunking, tested with runs
longer than the bound. Regression test fails on the old pattern (2.3 s).
The [src:N] header, the Source line and the closing reminder were plain text in
the same channel as the document, so a forum post containing a fake header
('[src:1] HED specification' on its own line, then a Source line) looked like a
real one and the model could cite the post under the specification's tag; the
reader would see the authoritative source with a real quote from it. Native
search_result blocks cannot be forged that way because their boundaries are
structural.

Text that reads like a tag ([src:N] in ASCII or fullwidth brackets, with the
spacing variants the parser accepts) is now written as (src:N) before it is shown
to the model, and the title and source are put on one line so they cannot start a
second header. The source list still quotes the document's own words. Tests are
adversarial (forged header, forged reminder, title and source with newlines,
fullwidth brackets) and fail without the change.
A text block split into cited segments took indexes 0..k, which collide with the
provider's own blocks after it: Qwen3 Next has no reasoning block, so its tool-use
block sits at index 1, and the second cited segment's block absorbed the tool
call's id, name and input when the streamed chunks were added together. tool_calls
stayed correct, but the stored content was corrupt. Segment indexes now start at
1,000,000, above any position a provider assigns. The test merges a cited text
block and a tool-use block and fails on the old indexes.
_select_model's provider annotation now includes 'bedrock' (a Bedrock provider
resolves its model the way Anthropic's does), and the search_result and cited-text
checks are TypeGuards so the block they test is narrowed to a dict where it is
used. No behavior change; ty reports nothing new against develop's baseline of
pre-existing diagnostics in these files.
_bedrock_choice refuses a caller's own Anthropic key and a deployment without a
Bedrock key. Applied to a community whose default_model is a Bedrock model (the
issue 514 case), that refused every request that named no model: the CLI, which
never sends one and can only use its own key, got a 403 telling it to remove its
key, and a deployment without AWS_BEARER_TOKEN_BEDROCK got a 400 for the whole
community. When nobody asked for the model, the request now runs the deployment's
Claude default (else Haiku 4.5) and logs an error naming the community. A caller
who names the Bedrock model still gets the refusal. Six routing tests.
…:variant ids

The warning says what a Bedrock default costs the callers who cannot have it (own
key with no model named, deployment without a Bedrock key) so it is seen at load
time, not in a log after the fact. The model-id pattern now allows a trailing
:variant, so Bedrock's own invoke id for gpt-oss-120b (openai.gpt-oss-120b-1:0),
already an accepted alias in requests and model_instructions, is accepted as a
default_model too; OpenRouter slugs such as ':free' benefit as well.
…ne at load

- The log formatter redacts Amazon Bedrock keys (long-term ABSK..., short-term
  bedrock-api-key-...) and any bearer credential in an Authorization header dump;
  botocore logs the whole request, header included, at DEBUG, and the raw key
  appeared in the output. The botocore logger is held at WARNING so the dump is
  not produced at all, since a record that reaches a handler other than ours (a
  tracing or error-reporting integration) is not redacted.
- Settings trims the key, treats a blank one as unset, and refuses one with
  whitespace inside. A trailing newline or CRLF made the HTTP client refuse the
  Authorization header, and its error names the header value, key included.
  Settings no longer echoes an input in a validation error
  (hide_input_in_errors), so a rejected key is not printed to the startup log.
Tests cover each format, the botocore dump line, the logger levels, and the
cleaning rules.
OSA prices ordinary = input_tokens - cache_read - cache_creation, which is right
only if input_tokens is the whole prompt. Measured against Bedrock: inputTokens is
the uncached remainder (2 of 9,216 on a repeated prompt) and langchain-aws adds the
cache read and write counts back, so the arithmetic holds; the test now says so
against the real service instead of only checking the library's addition.
The endpoint decides whether run 2 carries a result's images by asking the routing
that will run the model. Nothing covered a Bedrock model there. The synthetic
community now has an allowed origin, so a platform-funded request can resolve: a
Claude model on the platform key sends the image (the control), a Bedrock model
sends the placeholder. Fails if takes_native_blocks is wrongly true for Bedrock.
LangGraph's astream_events reads tokens from callbacks rather than from what
stream() returns, and ChatBedrockConverse reports each raw token to a run manager
when it is given one. The test drives astream_events over a fixture stream whose
tags are split across chunks and asserts the on_chat_model_stream events carry no
[src ...] text. It passes: langchain-core does not hand a run manager to _stream on
this path. The test keeps it that way.
Each request built two botocore sessions and two boto3 clients (80 ms of CPU on
the event loop's thread here) that never reused a connection. Clients are now
cached per (service, Region, key, timeouts); boto3 clients are safe to share
between threads and ChatBedrockConverse does not modify one it is handed. A model
is still built per request. Later builds take under a millisecond. The wire tests
clear the cache around each test, since they hook the client they are given.
…-free

langchain-aws has no async client, so an async stream waits for each chunk on a
worker thread, and a reasoning model can think for half a minute before its first.
On the event loop's default executor (cpu count + 4 threads, at most 32) that
capped concurrent streams at a handful on a small host and starved everything else
that uses the default executor. _astream now waits on a 64-thread pool of its own
(threads are made on demand).

_stream also stops handing the run manager to ChatBedrockConverse, which reports
each raw token, tags and all, and reports the tag-free ones itself. langchain-core
does not pass a run manager on the astream_events path, so nothing leaked, but its
protocol-streaming path does. Tests: tokens to a run manager carry no tag; the
async stream reads on the bedrock-stream threads; more concurrent streams than the
default pool has threads all finish. Each fails when the change is reverted.
…form-only

The config endpoint offered the Bedrock models whenever a Bedrock key was set, but
routing reaches Bedrock only from the Anthropic provider, so a deployment with a
Bedrock key and only an OpenRouter fallback listed models it then refused with a
misleading message. They are now offered when both keys are set. Each entry also
carries platform_only, so a menu can tell a reader with their own Anthropic key
(refused for these models) which ones that key cannot run. The request model's
description says so instead of claiming any caller may pick any offered model.
…wn Anthropic key

A saved Anthropic key and a Bedrock model chosen from the menu was a pairing the
server refuses with a 403 on the first message. With an Anthropic key in the
Settings field the service-only models are now disabled and say why, and saving
that pairing is refused in the dialog. An OpenRouter key runs the same models
there, so they stay available with it. The list comes from the config endpoint's
platform_only flag; a fallback list (checked against the backend's Bedrock models by
the drift test) covers the time before it loads. Three widget tests.
bedrock_llm.py relies on botocore internals (the bearer-token client) and on how
langchain-aws adds cache tokens to input_tokens. The lock pins 1.7.9, but an
unbounded range would let a routine update cross a major version unreviewed. The
wire tests assert both behaviors, so a bump inside 1.x is checked by the suite.
…g, streaming pool

ADR 0014, the changelog and the routing notes now say what the review changed:
a Bedrock default nobody chose falls back to Claude instead of refusing, community
Anthropic keys do not pay for Bedrock (stated as policy), retrieved text cannot
forge a source tag, streams wait on their own thread pool, the Bedrock key stays
out of logs, tool-call ids are unguessable, and the live tests are run by hand.
@neuromechanist
neuromechanist force-pushed the feature/issue-523-bedrock-models branch from e716748 to 5e29ced Compare September 29, 2026 04:38
Base automatically changed from feature/issue-523-bedrock-models to develop September 29, 2026 04:57
@neuromechanist
neuromechanist merged commit 95ef51c into develop Sep 29, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-526-openrouter-tagged-citations branch September 29, 2026 05:08
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