Skip to content

Release 0.8.16: Luna for HED, EEGLAB, BIDS and NWB; Bedrock models; reasoning effort - #562

Merged
neuromechanist merged 74 commits into
mainfrom
develop
Oct 1, 2026
Merged

neuromechanist merged 74 commits into
mainfrom
develop

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Promotes develop to main: the NWB community, GPT-6 Luna and two other models from Amazon Bedrock, community-controlled reasoning effort, and widget changes.
HED, EEGLAB and BIDS move to Luna (#559, #560), and NEMAR ships on Sonnet 5.5.

What reaches production

CHANGELOG.md has the full list under ## [0.8.16] (retitled in #573).

Other communities

Community default_model on main After this merge
HED claude-haiku-4-5 openai.gpt-6-luna, reasoning_effort: high
EEGLAB claude-haiku-4-5 openai.gpt-6-luna, reasoning_effort: high
BIDS claude-haiku-4-5 openai.gpt-6-luna, reasoning_effort: high
NEMAR claude-haiku-4-5 claude-sonnet-5-5, reasoning_effort: high
NWB (new) openai.gpt-6-luna, reasoning_effort: high
FieldTrip, MNE, MetaBCI, OpenNeuroPET claude-haiku-4-5 unchanged, but see below
  • Haiku's default thinking budget goes from 2048 to 4096 tokens (ADR 0015), so the four communities that stay on it, and every request that falls back to it, think longer and bill more output.
  • A request that names no model and cannot have Luna runs the deployment's Claude default (DEFAULT_MODEL, Haiku 4.5 unless changed). A deployment with ANTHROPIC_API_KEY but no Bedrock key logs an error naming the community on each such request; a caller's own Anthropic key (every CLI request) logs a warning. With no ANTHROPIC_API_KEY, the request goes to OpenRouter's Luna slug or fails with HTTP 500.
  • None of HED, EEGLAB or BIDS has a tool that returns an image, so Luna's lack of image blocks loses nothing; NEMAR's figures are why it stays on Sonnet.
  • The widget's bytes change (frontend/osa-chat-widget.js), so its integrity hash changes with them.

Issues

Closed by this merge:

Closes #515, closes #522, closes #523, closes #526, closes #531, closes #534, closes #536, closes #538, closes #540, closes #543, closes #545, closes #548, closes #550, closes #552, closes #559.

Left open on purpose:

Review

Decided by the maintainer: the model change (#560) and the changelog backfill (#561) went to develop without a separate review, to be covered here.
The full main...develop diff was reviewed three times, and the fixes are #563, #565, #566, #567, #568, #570, #571, #572 and #573.
The third review found no regression against main; #573 carries its fixes.

Version

src/version.py carries the .devN suffix. ensure-stable-version.yml strips it on main; it is not hand-bumped.

After merge

  • ensure-stable-version.yml sets 0.8.16 and tag-release.yml tags it
  • https://api.osc.earth/osa/health reports 0.8.16 after the hourly pull, and both AWS_BEARER_TOKEN_BEDROCK and ANTHROPIC_API_KEY are set on the production container (the Bedrock models are reachable only with both), so HED, EEGLAB, BIDS and NWB are served by Luna; with the Bedrock key missing they run Haiku 4.5 at about nine times the cost, with an error logged per request, and with no Anthropic key they go to OpenRouter or fail with HTTP 500
  • The widget on the sites that embed it (nemar.org pins the integrity hash) is re-pinned to the tagged commit
  • The issues above closed, NEMAR: default to GPT-6 Luna #530 closed as not planned, and Widget: configurable launcher size (closed and open) and screen position #553's follow-ups done
  • sync-develop.yml opens its PR into develop; if it fails, run the manual recovery

github-actions Bot and others added 30 commits September 25, 2026 01:57
…p-after-v0.8.15

chore: sync develop with main after v0.8.15
Communities funding themselves through OpenRouter can now use
openai/gpt-6-luna as their default model. Previously the cost guard
rejected it with 403 because it was missing from MODEL_PRICING.

Refs #514
Adds the NWB Assistant community: 105 PyNWB, HDMF, NeuroConv and NWB
Inspector docs from magland/nwb-doc-index (2 preloaded), a system
prompt adapted from the existing NWB Assistant, widget settings, and
CORS origins for the NWB docs sites. Platform-funded Haiku default for
now; GPT-6 Luna once it is offered through Bedrock.

Refs #514
* fix: valid LangFuse trace ids and metadata

LangFuse requires 32-char lowercase hex trace ids. The previous
'<community>-<12 hex>' ids were rejected, so the root span was never
created: each LLM and tool call became its own trace and
request_log.langfuse_trace_id matched nothing.

Traces now also carry the community as a tag, the X-User-ID as the
user, and the chat session id for /chat and streaming chat.

Refs #515

* feat: send feedback scores to LangFuse

POST /feedback now attaches thumbs up/down (and the comment) to the
rated answer's LangFuse trace as a user_feedback score, using
request_log.langfuse_trace_id. Best-effort: skipped when LangFuse is
not configured or the request was not traced, and errors are logged
without failing the request.

Refs #515
renderInlineMarkdown did not handle inline code; only markdownToHtml's
paragraph path converted backticks. List items, headings and table
cells therefore showed literal backticks, e.g. an NWB answer's
'* `session_description`: ...' list. Inline code is now matched in
renderInlineMarkdown (escaped, not parsed further), and paragraphs use
it directly.

Indented list items, which models use for nested lists, are now kept
in the list instead of becoming paragraphs with a literal '*'.

Adds frontend/test-markdown.js, run with Bun in the frontend-tests job.

Co-authored-by: Benjamin Dichter <[email protected]>
Adds pages the NWB doc index lacks: NWB Inspector CLI and library
guides, MatNWB quickstart/reading/creating, DANDI Dandiset creation,
metadata, validation and upload guides, the NWB overview intro and
file anatomy, the extension creation and publishing guides, and the
NWB schema release notes.

In a blind-graded 25-question evaluation these raised the overall
score from 4.22 to 4.61 out of 5, with no change in cost.

Refs #514
Adds the HDMF, NeuroConv, NWB Inspector, NWB overview and MatNWB docs
sites to the NWB community's cors_origins, so the NWB Assistant widget
can be embedded there alongside the PyNWB docs.

Refs #514
* Offer Claude Sonnet 5.5 in place of Sonnet 5

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.

* Default the NEMAR assistant to Sonnet 5.5

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.

* Count figures at the high-resolution image rate

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.

* Read FAQ replies through extract_text

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.

* Move a saved claude-sonnet-5 widget setting to Sonnet 5.5

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.

* Test the thinking-off request payload; refresh the eeglab comment

The payload for thinking=None on Sonnet 5.5 is asserted directly: between_tools,
and none of the parameters the model rejects.

* Note the widget and figure-count changes in the changelog

* Ask for the model first in the widget's Settings dialog

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.

* Run the Settings dialog tests in test.yml too

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.
* Add langchain-aws to the server extra

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.

* Add Bedrock credential and region settings

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.

* Add GPT-6 Luna, Qwen3 Next and gpt-oss-120b to the offered models

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.

* Add tagged-source citations for models without native citations

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.

* Add the Bedrock chat models

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.

* Keep another model's reasoning out of a replayed history

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.

* Add per-model prompt notes and community model_instructions

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.

* Route requests for the Bedrock models

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.

* Treat Bedrock reasoning blocks as thinking, not unknown content

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.

* End each tagged source with a reminder to tag claims drawn from it

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.

* Add live tests for the Bedrock models

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).

* Document the Bedrock models: ADR 0014, changelog, deploy variables

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.

* Bound the whitespace a citation tag takes so a whitespace loop cannot 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).

* Stop retrieved documents from forging citation tags

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.

* Keep synthetic citation block indexes clear of the provider's

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.

* Fix the type errors ty reports on the Bedrock routing and tag rewriting

_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.

* Run a Claude model when a community's Bedrock default cannot be served

_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.

* Warn when a community's default model is served from Bedrock; accept :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.

* Keep the Bedrock key out of logs and errors, and refuse a malformed one 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.

* Assert live that Luna's input_tokens count cached tokens once

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.

* Test /chat/resume image gating for a Bedrock model

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.

* Test that no citation tag reaches a token callback on the Bedrock path

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.

* Reuse the Bedrock boto clients instead of building two per request

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.

* Wait on Bedrock streams in a pool of their own, and report tokens tag-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.

* List Bedrock models only where they can be routed, and flag them platform-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.

* Widget: show the Bedrock models as unavailable next to the reader's own 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.

* Cap langchain-aws below 2.x

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.

* Document the review changes: fallback default, key policy, tag forging, 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.
…nd each call's own key (#528)

* Offer Claude Sonnet 5.5 in place of Sonnet 5

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.

* Default the NEMAR assistant to Sonnet 5.5

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.

* Count figures at the high-resolution image rate

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.

* Read FAQ replies through extract_text

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.

* Move a saved claude-sonnet-5 widget setting to Sonnet 5.5

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.

* Test the thinking-off request payload; refresh the eeglab comment

The payload for thinking=None on Sonnet 5.5 is asserted directly: between_tools,
and none of the parameters the model rejects.

* Note the widget and figure-count changes in the changelog

* Ask for the model first in the widget's Settings dialog

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.

* Run the Settings dialog tests in test.yml too

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.

* Add langchain-aws to the server extra

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.

* Add Bedrock credential and region settings

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.

* Add GPT-6 Luna, Qwen3 Next and gpt-oss-120b to the offered models

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.

* Add tagged-source citations for models without native citations

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.

* Add the Bedrock chat models

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.

* Keep another model's reasoning out of a replayed history

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.

* Add per-model prompt notes and community model_instructions

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.

* Route requests for the Bedrock models

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.

* Treat Bedrock reasoning blocks as thinking, not unknown content

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.

* End each tagged source with a reminder to tag claims drawn from it

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.

* Add live tests for the Bedrock models

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).

* Document the Bedrock models: ADR 0014, changelog, deploy variables

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.

* Bound the whitespace a citation tag takes so a whitespace loop cannot 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).

* Stop retrieved documents from forging citation tags

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.

* Keep synthetic citation block indexes clear of the provider's

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.

* Fix the type errors ty reports on the Bedrock routing and tag rewriting

_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.

* Run a Claude model when a community's Bedrock default cannot be served

_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.

* Warn when a community's default model is served from Bedrock; accept :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.

* Keep the Bedrock key out of logs and errors, and refuse a malformed one 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.

* Assert live that Luna's input_tokens count cached tokens once

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.

* Test /chat/resume image gating for a Bedrock model

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.

* Test that no citation tag reaches a token callback on the Bedrock path

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.

* Reuse the Bedrock boto clients instead of building two per request

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.

* Wait on Bedrock streams in a pool of their own, and report tokens tag-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.

* List Bedrock models only where they can be routed, and flag them platform-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.

* Widget: show the Bedrock models as unavailable next to the reader's own 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.

* Cap langchain-aws below 2.x

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.

* Document the review changes: fallback default, key policy, tag forging, 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.

* Move chunk retagging next to the tag parser so any chat model can use it

ChunkRetagger holds the per-block MarkerStreams that TaggedCitationChatBedrock kept
in a dict, with the same behavior. Tested with plain string chunks, chunks split at
every size, held-back text at the end of a reply, and pass-through of tool-call
chunks, usage and reasoning blocks. Bedrock tests unchanged and passing.

* Replace the LiteLLM caching wrapper with a ChatLiteLLM subclass

CachingLLMWrapper held a ChatLiteLLM and forwarded to it, so it had to be
re-applied around every bind_tools result and could not see the reply it would
need to rewrite. TaggedCitationChatLiteLLM is a ChatLiteLLM: bind_tools and the
streaming entry points stay native, and three things happen at the model
boundary.

- Cache breakpoints on the system prompt and the last message, as before
  (to_message_dicts carries the wrapper's message conversion over; tool results
  and earlier assistant turns are now flattened to their text blocks instead of
  str() of the block list).
- search_result blocks in tool results are shown to the model as [src:N] tagged
  text and the tags it writes come back as citations, through the same
  tagged_citations layer the Bedrock models use.
- Cache reads and writes and reasoning tokens in the raw usage are carried onto
  usage_metadata, where the metrics price them.

The wrapper's tests are ported to to_message_dicts; the new behavior is tested
against a local fake OpenRouter that speaks the chat-completions wire format, so
the real LiteLLM and OpenAI client stack runs. Not verified against the real
OpenRouter service (no key on this machine); the live tests are in the next
commits.

* Send the OpenRouter key with each call, not through litellm's module globals

ChatLiteLLM writes its credentials onto the litellm module, which every instance
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. A key in the call arguments takes
precedence over the module's, so _client_params now carries it.

The regression test runs 40 concurrent requests under two keys against the fake
OpenRouter and fails without the change (20 of 40 wrong).

* Give OpenRouter requests tagged citations in place of the markdown-link prompt

Every provider choice now cites its sources: native search_result blocks on
Anthropic, tagged sources on Bedrock and OpenRouter. Tools return search_result
blocks on the OpenRouter path and the model layer turns them into [src:N] text and
back into citations, so the widget shows the same numbered markers and source list
it shows for Claude. The 'Source Links Required' section remains for callers that
build an assistant directly with citations off.

* Test the OpenRouter model's tokens, forged headers and block indexes

Adds what the review of the Bedrock branch found to the OpenRouter path: tokens
reported to a run manager are tag-free (and use the message's text, as the Bedrock
model now does), a document cannot forge a source header in a request, and cited
text followed by a tool call keeps its blocks apart through ChunkRetagger.

* Add live OpenRouter tests for tagged citations, caching and reasoning tokens

Skipped without OPENROUTER_API_KEY_FOR_TESTING, and not run: there is no OpenRouter
key on the development machine. They assert what only the service can show: the
tool loop's second call is accepted with tagged tool 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.

* Document OpenRouter citations and the key-mixing fix

* Run a community assistant through a full tool loop on an OpenRouter model

The pieces are tested separately; this runs the real HED assistant (its system
prompt and tools), the real LangGraph agent, the real OpenRouter chat model against
the fake OpenRouter, and the API layer's answer assembly: the prompt asks for tags
and not for markdown links, the tool result reaches the model as tagged text, the
answer and source list a client receives are numbered, and a follow-up turn sees
the earlier answer with its tags instead of citation dicts. The fake server moves
to tests/helpers/openrouter.py so both files use it.

* Read OpenRouter's usage beneath LiteLLM's stream wrapper

OpenRouter documents its usage as a chunk that repeats the finish_reason after the
real finish chunk. LiteLLM's wrapper emits its own final usage chunk at the first
finish, before it has read the rest of the provider's stream, and never uses the
provider's: what a reply reported was a local token estimate with no cache or
reasoning counts (input 8, output 1 for a 100-token prompt in the fake). Only a
provider that put usage on its one finish chunk was read correctly.

A tap on the wrapper's completion_stream now sees the provider's usage, the
wrapper's own is held back, and the provider's is sent as the stream's last chunk
(the wrapper's estimate stands for a provider that reports none). Sync and async,
three chunk shapes (documented, on the finish chunk, trailing), the no-usage case,
and one count per call across a tool loop are tested. The tap depends on LiteLLM's
completion_stream attribute; the lock pins the version and the tests fail if it
moves.

* Build OpenRouter request parameters without LiteLLM's shared module

ChatLiteLLM._client_params writes the caller's key (and headers and base URL) onto
the litellm module on every call. The per-call key already won, but the module kept
the last caller's key for any later call that omitted one. _client_params is now
built from the instance alone, refuses a model with no key instead of borrowing
one, and sets stream from the call: invoke(stream=False) on a streaming model sent
stream: true and then read a generator as a reply. Tests: nothing is left on the
module, a keyless model raises, and stream=False works sync and async.

* Keep LiteLLM's loggers quiet so a caller's key is not logged at DEBUG

The key travels with each completion call now, and LiteLLM logs a call's arguments
at DEBUG on a logger that reaches the root: with the root at DEBUG a caller's key
appeared in the records (the previous, shared-module design did not log it). The
redacting formatter covers only this process's own handler and standard key
formats, so, as for botocore, the loggers are held at WARNING. The test runs a
call with a capturing root handler at DEBUG and fails without the change.

* Keep each retrieved source on lines of its own in an OpenRouter tool result

A tool result is one text block per source, and the blocks were joined with nothing:
the next source's [src:N] header ran on from the previous source's closing reminder
('...after the sentence.)[src:2] B two'), which is the layout the forgery defense
assumes a real header does not have. Blocks of a tool or system message are now
separated by a blank line; an assistant turn's segments are still joined as written,
since they carry their own whitespace.

* Send cache markers only to models that take them

LiteLLM drops cache_control for any OpenRouter slug that is not Anthropic's but
keeps the message reshaped into a one-part list, so the default configuration sent
every other model (GPT-6 Luna, Qwen3 Next, gpt-oss-120b) a list where a string
works, with nothing gained; a strict provider could refuse it. The last message and
the system prompt are now plain strings for those models. OpenAI's models cache a
repeated prefix on their own.

* Cover the OpenRouter model's remaining entry points and concurrent sync use

Mutations that survived the review of this branch now fail: dropping the held-back
tail of a stream (a reply ending on a partial tag or a space), skipping the tag
rewrite in _agenerate, leaving the stream branch of _generate/_agenerate untested,
and the key going out through anything but the call (now also checked from threads,
which is how the agent's model node calls it). The fake OpenRouter records each
request with its headers as one entry, keeps connections alive, and has a listen
backlog that a dozen threads do not overflow (5 reset connections on macOS).

* Fix documentation that still described OpenRouter as citation-free

CitationInfo's docstring (part of the OpenAPI schema), the create_community_assistant
docstring, a widget comment, the fallback-prompt test's docstring and the routing
notes described the OpenRouter path as it was before tagged citations, or read as if
the OpenRouter factory were a Bedrock step. The browser-execution design note still
named the removed CachingLLMWrapper; it now says what replaced it. The changelog
says the cost figures come from the provider's own usage and should be checked
against the live service.

* Add langchain-aws to the server extra

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.

* Add Bedrock credential and region settings

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.

* Add GPT-6 Luna, Qwen3 Next and gpt-oss-120b to the offered models

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.

* Add tagged-source citations for models without native citations

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.

* Add the Bedrock chat models

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.

* Keep another model's reasoning out of a replayed history

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.

* Add per-model prompt notes and community model_instructions

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.

* Route requests for the Bedrock models

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.

* Treat Bedrock reasoning blocks as thinking, not unknown content

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.

* End each tagged source with a reminder to tag claims drawn from it

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.

* Add live tests for the Bedrock models

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).

* Document the Bedrock models: ADR 0014, changelog, deploy variables

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.

* Bound the whitespace a citation tag takes so a whitespace loop cannot 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).

* Stop retrieved documents from forging citation tags

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.

* Keep synthetic citation block indexes clear of the provider's

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.

* Fix the type errors ty reports on the Bedrock routing and tag rewriting

_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.

* Run a Claude model when a community's Bedrock default cannot be served

_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.

* Warn when a community's default model is served from Bedrock; accept :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.

* Keep the Bedrock key out of logs and errors, and refuse a malformed one 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.

* Assert live that Luna's input_tokens count cached tokens once

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.

* Test /chat/resume image gating for a Bedrock model

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.

* Test that no citation tag reaches a token callback on the Bedrock path

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.

* Reuse the Bedrock boto clients instead of building two per request

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.

* Wait on Bedrock streams in a pool of their own, and report tokens tag-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.

* List Bedrock models only where they can be routed, and flag them platform-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.

* Widget: show the Bedrock models as unavailable next to the reader's own 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.

* Cap langchain-aws below 2.x

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.

* Document the review changes: fallback default, key policy, tag forging, 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.
* Offer Claude Sonnet 5.5 in place of Sonnet 5

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.

* Default the NEMAR assistant to Sonnet 5.5

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.

* Count figures at the high-resolution image rate

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.

* Read FAQ replies through extract_text

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.

* Move a saved claude-sonnet-5 widget setting to Sonnet 5.5

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.

* Test the thinking-off request payload; refresh the eeglab comment

The payload for thinking=None on Sonnet 5.5 is asserted directly: between_tools,
and none of the parameters the model rejects.

* Note the widget and figure-count changes in the changelog

* Ask for the model first in the widget's Settings dialog

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.

* Run the Settings dialog tests in test.yml too

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.

* Add langchain-aws to the server extra

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.

* Add Bedrock credential and region settings

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.

* Add GPT-6 Luna, Qwen3 Next and gpt-oss-120b to the offered models

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.

* Add tagged-source citations for models without native citations

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.

* Add the Bedrock chat models

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.

* Keep another model's reasoning out of a replayed history

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.

* Add per-model prompt notes and community model_instructions

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.

* Route requests for the Bedrock models

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.

* Treat Bedrock reasoning blocks as thinking, not unknown content

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.

* End each tagged source with a reminder to tag claims drawn from it

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.

* Add live tests for the Bedrock models

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).

* Document the Bedrock models: ADR 0014, changelog, deploy variables

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.

* Bound the whitespace a citation tag takes so a whitespace loop cannot 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).

* Stop retrieved documents from forging citation tags

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.

* Keep synthetic citation block indexes clear of the provider's

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.

* Fix the type errors ty reports on the Bedrock routing and tag rewriting

_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.

* Run a Claude model when a community's Bedrock default cannot be served

_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.

* Warn when a community's default model is served from Bedrock; accept :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.

* Keep the Bedrock key out of logs and errors, and refuse a malformed one 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.

* Assert live that Luna's input_tokens count cached tokens once

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.

* Test /chat/resume image gating for a Bedrock model

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.

* Test that no citation tag reaches a token callback on the Bedrock path

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.

* Reuse the Bedrock boto clients instead of building two per request

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.

* Wait on Bedrock streams in a pool of their own, and report tokens tag-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.

* List Bedrock models only where they can be routed, and flag them platform-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.

* Widget: show the Bedrock models as unavailable next to the reader's own 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.

* Cap langchain-aws below 2.x

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.

* Document the review changes: fallback default, key policy, tag forging, 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.

* NWB: default to GPT-6 Luna

The NWB team's evaluation of 25 real questions (issue 514) used GPT-6 Luna and found
it competitive with their existing assistant; OSA now serves it from Amazon Bedrock.
A widget request that names no model runs Luna at maximum reasoning effort on the
platform's Bedrock key; a caller with their own Anthropic key who names no model
(the CLI), and every request on a deployment without a Bedrock key, runs Claude
Haiku 4.5 instead. NWB's budget ($5 a day, $50 a month) is unchanged and now goes
much further: Luna is $0.11 / $0.55 per 1M tokens against Haiku's $1 / $5.
Checked against the real service: a widget-origin request resolves to Luna on
Bedrock, an own-key request to Haiku, and a server with no Bedrock key to Haiku.

* Add langchain-aws to the server extra

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.

* Add Bedrock credential and region settings

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.

* Add GPT-6 Luna, Qwen3 Next and gpt-oss-120b to the offered models

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.

* Add tagged-source citations for models without native citations

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.

* Add the Bedrock chat models

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.

* Keep another model's reasoning out of a replayed history

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.

* Add per-model prompt notes and community model_instructions

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.

* Route requests for the Bedrock models

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.

* Treat Bedrock reasoning blocks as thinking, not unknown content

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.

* End each tagged source with a reminder to tag claims drawn from it

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.

* Add live tests for the Bedrock models

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).

* Document the Bedrock models: ADR 0014, changelog, deploy variables

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.

* Bound the whitespace a citation tag takes so a whitespace loop cannot 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).

* Stop retrieved documents from forging citation tags

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.

* Keep synthetic citation block indexes clear of the provider's

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.

* Fix the type errors ty reports on the Bedrock routing and tag rewriting

_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.

* Run a Claude model when a community's Bedrock default cannot be served

_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.

* Warn when a community's default model is served from Bedrock; accept :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.

* Keep the Bedrock key out of logs and errors, and refuse a malformed one 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.

* Assert live that Luna's input_tokens count cached tokens once

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.

* Test /chat/resume image gating for a Bedrock model

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.

* Test that no citation tag reaches a token callback on the Bedrock path

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.

* Reuse the Bedrock boto clients instead of building two per request

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.

* Wait on Bedrock streams in a pool of their own, and report tokens tag-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.

* List Bedrock models only where they can be routed, and flag them platform-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.

* Widget: show the Bedrock models as unavailable next to the reader's own 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.

* Cap langchain-aws below 2.x

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.

* Document the review changes: fallback default, key policy, tag forging, 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.
* Widget: reveal streamed text at a reading pace, code blocks whole

Refs #531. Luna at max effort thinks silently, then emits over 1000 chars/s,
so a fine stream read as everything at once. The widget now paces the
delivered text (300 chars/s floor, catch-up within ~1.5 s), shows fenced code
whole, and skips pacing under prefers-reduced-motion. Tested with the new
frontend suite in the next commit.

* Test the paced reveal: planner, controller on a fake clock, real widget

Refs #531. 68 checks; broken three ways (code paced, no reveal, no floor) and
each is caught. Wired into test.yml and tests.yml.

* Note the paced reveal in the changelog

Refs #531.

* Widget: coalesce reduced-motion redraws, survive a throwing redraw, keep the reader's place

Refs #531, review findings. Unpaced mode redrew per chunk (the 100 ms throttle
was gone): now one redraw per tick. A redraw that threw inside a timer left the
stream promise pending and the input disabled: the controller now catches it,
releases waiters and check() rethrows it. Also: sources appear with their
marker, no redraw over a focused textarea, no scroll yank for a reader who
scrolled up, a reveal never ends inside [n] or a surrogate pair, and a hidden
tab or page hide flushes the reveal so the reply is shown and saved.

* Test the review findings: redraw cost, throwing redraw, timers, sources, focus, scroll, page hide

Refs #531. 112 checks; each new behavior broken once and caught (the throwing
redraw by a crash with exit 1).

* Correct the paced reveal changelog entry

Refs #531.
Refs #530. Tested: config and routing suites (655 passed); routing checked
for the widget (Luna), the CLI with an own Anthropic key (Haiku) and a server
with no Bedrock key (Haiku).
…ome (#535)

* Widget: do not pace a reply on a page that is hidden

Refs #534. Pacing is asked at each tick, so a page already hidden when the
reply starts (visibilitychange fired before the stream, so the flush on hide
never ran) gets everything at the next tick, not a reveal at the throttled
one-a-second rate. Tested in the Bun suite (116 checks); broken once to see it
caught.

* Check the paced reveal in real Chrome, on its own server

Refs #534. A Luna-shaped burst (1.5 s silent, then a reply with a code block
in about 40 ms) is replayed from a local server and what the reader sees is
sampled in the page. Controls: page visible, stream really a burst, fresh
conversation, and prefers-reduced-motion emulated by the browser. With pacing
removed it fails 5 checks and exits 1. In the Frontend Tests job of both
workflows; needs no backend and no network.

* Note that a hidden page is not paced

Refs #534.

* Account for the paced-reveal check's harness page in the embed hygiene test

Refs #534. The new check's own page loads the widget from its loopback server;
it is a dev harness page like widget-e2e.html, never embed guidance. Full
offline suite: 3273 passed.
neuromechanist and others added 2 commits September 30, 2026 15:12
* Widget: find inline code spans before emphasis so globs like *.set and `*.fdt` render

An italic match starting before a code span swallowed it, so
"Use *.set or `*.fdt` files" rendered as <em>.set or `</em>.fdt`.
renderInlineMarkdown now lifts code spans out first and puts them back as
<code> (or raw backticks inside an address), so code inside bold, italic
and link text renders too. Tested: frontend/test-markdown.js (13 new cases).

* Widget: give the status line's pulse its own keyframes name

A second @Keyframes osa-pulse replaced the header status dot's (opacity 1 to
0.4) with the status line's (0.25 to 1). The status line now uses
osa-activity-pulse. frontend/test-widget-activity-status.js checks that the
stylesheet defines each keyframes name once and that every animation started
has keyframes. Tested: that suite passes.

* Widget: keep the API key field in view while it has focus

Emptying the key with a non-Custom model hid the field under the cursor,
dropping keyboard focus to the page. The field now stays while focused and is
put away on blur; a press on a dialog button defers that until the click has
landed, since the dialog is centred and hiding a field moves Save.
Tested: frontend/test-widget-settings.js (6 new checks; 2 fail on the old code).

* Widget: hold typed and saved models to the server's model and key rules

Settings checked a service-only model against an Anthropic key only for a menu
pick: a custom openai.gpt-oss-120b saved and then 403'd on every send, and a
custom openai/gpt-5 with an Anthropic key 400'd. One rule (modelKeyProblem,
from _select_model, _bedrock_choice and _route_request) now covers the custom
field and the menu, and is applied to saved settings: the platform-only rule at
load, the offered-list rules once the community's own list arrives (a pinned
widget may be older than its backend), each resetting the model with a notice.
Default names no model, so it is not held to the rule: the server swaps a
Bedrock default it cannot run on the caller's key for a Claude model.
The widget now holds every alias in MODEL_ALIASES, so claude-haiku-4.5 and
claude-sonnet-4.5 come back as the offered model, not Custom; a drift test
keeps the two tables equal.
Tested: frontend/test-widget-settings.js (new cases fail on the old code) and
tests/test_frontend.

* Widget: select Default when the saved model is the community default

The default is left out of the menu's options (it is the Default entry), so a
saved model equal to it, such as claude-sonnet-5 mapped to claude-sonnet-5-5
on NEMAR or a model picked before a community made it the default, left the
menu blank, and saving from there stored an empty model. The match is made on
the model an id stands for, for the default as well as the saved value.
Tested: frontend/test-widget-settings.js (10 checks fail on the old code).

* Widget: give a capsule circle back its focus when a resize reorders them

arrangeCapsule re-appends the circles when the window crosses 600px, and moving
a node takes keyboard focus from it. Whichever circle had focus gets it back.
Tested: frontend/test-widget-launcher-geometry.js (4 checks fail on the old code).

* Widget: keep a finished reply whole when the reveal's redraw fails

A redraw error raised by reveal.check() inside the done handler skipped
applyDoneEvent, so the canonical text, citations and request id were lost and
a completed answer was labeled 'Stream interrupted'. The handler now applies
and saves the reply first and raises the page's failure after it, and the
error path adds no interruption note once done has been received.
Tested: frontend/test-widget-paced-streaming.js (5 checks fail on the old code).

* Widget: say what leaving the page does and does not save

The comment on the pagehide handler said the rest of a reply is 'saved' when the
page is left, but nothing there saves: showing the rest releases the wait that
holds a reply whose done has arrived, so its done handler saves it at once, and
a reply still streaming is saved only by its own done. Comment corrected, no
behaviour change; a test pins that a still-streaming reply is not saved by
pagehide. Tested: frontend/test-widget-paced-streaming.js.

* Harness: launch Chrome a second time, in a fresh profile, before failing

A release PR run failed with 'Chrome did not report a DevTools endpoint' after
30 seconds. launch() now kills that Chrome and starts another, in its own
profile, waiting 90 seconds for its endpoint; only a second silence fails the
run. Every Chrome check goes through launch(), so all are covered.
Tested: tests/test_frontend/test_chrome_launch.py runs the real launch() against
a stand-in executable that is silent on its first start; the real Chrome checks
still pass.

* Harness: bound what is timed by how late the runner was, not by a fixed clock

The paced-reveal, activity-status and launcher-geometry checks held a shared
runner to numbers measured on a quiet laptop. Each timed bound is now stretched
by how late the page's own sampler ran in the window it times (capped), so the
same bound holds when nothing stalled; the wait's digits are held to the clock
and to each other instead of to fixed seconds; frame counts follow the run's
frame rate, keeping one in-between frame as the floor against a snap.
Tested in real Chrome: all three pass; a stream 2.3 s slower fails the old
fixed-digit check and passes the new one; a widget that restarts the wait at
each label still fails it.

* Harness: load serve.js only where the server is started

chrome.js imported serve.js at the top, and serve.js needs the pyodide
package, which only the Frontend job installs. The new launch tests in
tests/test_frontend import chrome.js, so they failed in the Python test
job (Cannot find module 'pyodide/package.json') while passing locally
where node_modules existed. serve.js is now imported inside main(), the
only place startServer is used.

Tested: tests/test_frontend passes (112) with no node_modules present;
the 5 launch tests failed the same way before the change.
neuromechanist and others added 2 commits September 30, 2026 15:36
…s, error classification (#568)

* Read only a model provider's errors as a model call's failure

httpx errors, the built-in TimeoutError and any ConnectionError were labelled
'Model call failed', logged at WARNING with no traceback, and a 404 from a tool's
fetch told the reader retrying will not help. langgraph's ToolNode re-raises
uncaught tool errors, so a tool failure was misattributed. An exception now counts
as the model call's only when its class comes from a provider library (Anthropic,
OpenAI/LiteLLM, the vendored httpx2) or, for the built-in ConnectionError, when
langchain-aws raised it. Anything else keeps ERROR and its traceback.

Tested: real tools raising each error through the ask and chat streams, and the
real Bedrock client for the langchain-aws ConnectionError.

* Tell the reader when a reply is empty, whatever the stop reason; send a full context to a new conversation

A reply with no text, no code and no parked call ended in an empty done (which the
widget drops silently) unless it had hit the output limit: a refusal, content filter,
guardrail or malformed tool use left the reader with nothing. It is now an error for any
stop reason, with its own message per reason, the stop reason in the log and the metrics
row, and a 502 on the non-streamed endpoints. A conversation that filled the context
window was told to try again or ask it to continue, which fails again; it now says to
start a new conversation.

Tested: every stop reason in the registry through the streamed and non-streamed ask and
chat paths on the Bedrock, Anthropic and OpenRouter shapes. The client-tool streaming
tests that ended a turn on text now stream it, as a provider does.

* Count only browser runs the widget keeps when deciding an empty ending is fine

The server treated every resumed browser run as code the widget would keep on the
reply. The widget records a run only when the tool is not get_full_output, so a reply
whose only run read output back and whose last run hit the output limit with no text got
a warning and an empty done, which the widget drops: a banner and no answer. The parked
call now carries how many of its runs are code (PendingClientCall.code_runs_before,
runs_code), and only those make an empty ending a warning; otherwise it is an error.

Tested: through the real /chat/resume endpoint for each provider shape (read-back only,
code, code earlier in the reply) and the run counts carried across parked calls.

* Send one warning per reply, with a machine-readable code

A reply cut off in a long conversation got the cut-off warning and then the
'Conversation is getting long' warning straight after it. The widget keeps one warning
element, so the second overwrote the first unread, in exactly the conversations where
truncation is likeliest. They are now one event. Every warning event also carries an
optional code (cut_off, long_conversation; codes lists both when both apply) so a client
can act on the kind; message is unchanged, so existing clients work as before.

Tested: through the streamed chat with a conversation filled past the token budget on each
provider shape (combined, long only, cut off only, full context window), the ask stream,
and the event builder directly.

* Give error events the ids a report needs; keep the cannot-retry message short

The error events for an empty or cut-off reply carried no request_id or error_id, so a
reader's report could not be tied to the 502 row in the metrics or to its log line. They
now carry both (the error id is also in the log line), and so do model-call failure events.
The cannot-retry message held a UUID in text the widget shows for five seconds; the error id
is now only a field of the event and the log, and the message fits at a glance.

Tested: ids on the error event match the metrics row and the log record on each provider
shape, ask and chat streams, and every permanent model failure.

* Declare the 502 on /ask and /chat

Both endpoints return 502 when the model wrote no answer, but their route declarations
listed only 200, 400 and 500, so the OpenAPI schema did not say so.

Tested: the generated schema for both routes.

* CLI: print warnings under the answer on the streaming paths too

The streaming ask and chat printed a warning as its event arrived, above the answer;
the batch paths printed it below. The streaming paths now hold warnings until the answer
is printed. An error event's request and error ids are shown as a hint to quote in a report.

Tested: the printed order on all four paths with both consoles writing to one buffer,
several warnings, a stream with no answer, and the id hint.

* Non-streamed /chat: count only this request's runs in the cost row

The state a non-streamed /chat gets back holds the session's whole history, and
extract_token_usage summed the usage of every model message in it. A session that had a
browser turn keeps the model's own messages (replace_history adopts the graph state whole),
so later requests were billed for those runs again. The usage is now read from the messages
after the last human one, the same slice the cut-off check already used.

Tested: a session holding two earlier model runs with usage, then a non-streamed chat on each
provider shape; the cost row is the request's own (was three times it).

* Document what a failed stream leaves in the session, and pin how each provider takes it

A turn that ends on an error leaves the reader's message with no reply, and the next
message lands right behind it. That stays as it is; the comment where the turn ends says
so, and a test reads what each provider sends for two human messages in a row. Bedrock
merges them (merge_message_runs) and so does Anthropic (its own _merge_messages); the
OpenRouter path sends two consecutive user messages.

Tested: the real /chat endpoint twice per provider, the first request failing, through
the real Bedrock, Anthropic and LiteLLM clients with only the network staged.
neuromechanist and others added 2 commits September 30, 2026 16:00
* Widget: stack warnings so a second one does not replace the first

showWarning wrote every warning into one text node, so a cut-off notice and the
long-conversation notice that follows it were never both readable. Each warning
is now its own line with its own 10 s timer; the banner hides with the last
line; identical text restarts the one line's timer.

Tested: new cases in frontend/test-widget-paced-streaming.js (failed before the
change); bun frontend/test-widget-color-scheme.js unchanged.

* Widget: mark a cut-off reply in place and keep the mark across a reload

When a warning arrives before done and says the reply was cut off (code
cut_off when the server sends one, else the server's wording), the reply gets
a cutOff mark. The message draws the existing italic 'Response may be
incomplete' note from that mark once its text is fully shown, so the done
event's canonical text does not replace it. The mark is saved with the
conversation and read back only as a boolean.

Tested: new cases in frontend/test-widget-paced-streaming.js (failed before the
change), including a saved-and-reloaded conversation.

* Widget: keep a cut-off reply that has no text and no run record

applyDoneEvent kept an empty reply only if it had entries in executions, but
answerToolRequest records only code that ran, so a reply whose only run was
get_full_output had none. The server sends a warning and a done with empty
content for it (the run counts as code there), and the bubble was dropped,
leaving the 10 s banner as the only explanation. A reply marked cutOff is now
kept and draws the explanation the mark carries.

Tested: frontend/test-streaming.js and frontend/test-widget-paced-streaming.js
(new cases failed before the change).

* Widget: show the warnings of a non-streamed response

The non-streamed fallback ignored data.warnings, so a cut-off answer arrived
unmarked. Warnings (strings, or objects with a message and an optional code)
now go through the same function as a stream's warning events: the banner,
and the cutOff mark on the reply, which is saved with it. A missing or
malformed field is ignored.

Tested: new cases in frontend/test-widget-paced-streaming.js (failed before the
change).

* Widget: do not rewrite a server error that contains the word timeout

A backend error event whose text contained 'timeout' was rewritten to
'Stream timeout' in the reply when partial text was visible, and one that
contained 'JSON' became 'Invalid response from server' in the banner. The
error raised for an error event is now marked serverReported, and both
handlers pass it through as sent before looking for failures of the stream or
the page. A client-side stream failure that says timeout still reads as one.

Tested: new cases in frontend/test-widget-paced-streaming.js (failed before the
change).

* Widget: keep a failed request's banner, hand the question back, show the error id

The banner for a failed chat request lasted 5 s, and when the reply was empty
(the routine no-answer error) the question was removed with it, so the reader
lost both. Now, for a failed request:
- the banner stays until dismissed or the next send, with a dismiss button,
  selectable text, and the server's error_id (when the event carries one) as
  text with a copy button (falling back to selecting it where the page cannot
  copy);
- the question goes back in the input when the failure removed it from the
  conversation; an error after a partial reply keeps it there, as before;
- an earlier message's timer no longer hides a later message's banner.
Other banners (settings, feedback, storage) still go after 5 s.

Tested: new cases in frontend/test-widget-paced-streaming.js (failed before the
change); every frontend suite in the Frontend Tests job run locally.

* Widget: read the server's cut-off warnings as #568 sends them

#568 gives each warning a code and sends one combined notice (code cut_off,
codes listing both) when a cut-off and a long conversation coincide, and adds a
context-window cut-off whose message is 'stopped short because' and whose advice
is to start a new conversation, not to ask it to continue. So:
- the wording fallback for a warning with no code (a stream before #568, and a
  non-streamed response's warnings, which are strings) also reads that message;
- the note under a cut-off reply's text says only that it was cut off, true for
  either cause; a reply with no text shows the server's own message for it, kept
  on the reply (bounded, saved and read back only as a string), so the advice is
  the server's and survives a reload;
- tests read the server's message constants from src/api/turn_outcome.py.

Tested: bun frontend/test-widget-paced-streaming.js.
neuromechanist and others added 2 commits September 30, 2026 16:23
markdownToHtml ended with `return result || text`, so a reply that was
only an opening fence rendered no block and its raw text was returned as
HTML for innerHTML. A fence info string such as <img src=x onerror=...>
became a live element, and the model (or a document steering it) controls
that text; streaming could also reach it transiently. The text is now
escaped. The same file on main also passed a "<" in a paragraph through
unescaped; the paragraph path rewritten for this release already
escapes it, and a test now pins that too.

Tested: frontend/test-markdown.js 31 passed; the two new fence tests fail
on the unfixed widget. An HTML parse (happy-dom) of the output showed an
IMG with an onerror attribute for both inputs on main and for the fence
input on develop before this change, and none after.
neuromechanist and others added 2 commits September 30, 2026 17:01
* Do not store whitespace-only assistant text as a turn

A reply that ran code counts as answered with no text, so a reply whose text was only
whitespace passed the emptiness check and was stored. langchain-anthropic replays it
unchanged and Anthropic rejects a whitespace-only text block, so every later turn of the
session would have failed. The store now tests the stripped text, streamed and not.

Tested: new failing-first tests (scripted model on each provider path, and the real
Anthropic client's request body); tests/test_api/test_cut_off_replies.py passes.

* Say whose key was refused instead of telling everyone to start over

A provider failure no retry can fix always told the reader to start a new conversation.
For a refused credential that cannot help: a caller's own (BYOK) key is now named as theirs
to check, and logged at WARNING without a traceback since the operator did nothing wrong;
a platform or community key says it is a server problem and keeps the ERROR with its
traceback. /ask no longer offers a conversation it does not have.

Tested: new tests through the real Anthropic client for each key source on /ask and /chat;
test_stream_failures.py and test_unanswered_user_message.py pass.

* Return the error id and request id in the 502 of a reply that is not streamed

The streamed error event carries both; the 502 for a non-streamed empty reply only logged the
error id, so a client that retries on a 502 could not tie its attempts to the log or to the
metrics row. The body keeps detail as the text to show (the CLI reads it there) and adds
error_id and request_id, declared in the OpenAPI schema for /ask and /chat.

Tested: new tests on the real /ask and /chat endpoints for each provider path, and on the
declared schema; test_cut_off_replies.py and test_turn_outcome.py pass.

* Report no provider hint for the Claude fallback default in /config

When a community's Bedrock default cannot be served, /config showed the platform's
default_model_provider (DeepInfra/FP8 by default) next to a Claude model. That hint is an
OpenRouter upstream host; a request for a bare Claude id carries none, so report None.

Tested: test_bedrock_deployments.py updated to expect None (failed before the change, passes
after).

* Read a community's own key when reporting what its Bedrock default runs

_bedrock_default_outcome, the /config default and model menu, and the startup log read the
platform's keys alone, so a community that names its own anthropic_api_key_env_var or
openrouter_api_key_env_var (and has it set) could run a different model than they said.
The precedence _resolve_provider applies (Anthropic variable first, naming it settles it)
now lives in _community_key, and _resolve_provider and a new _funded_provider both use it.
No shipped config sets these variables; the startup log now judges each community on its
own key and names the variable.

Tested: a matrix over every platform key combination and every state of both community
variables, comparing /config, the model menu and the startup log to the route a request
takes (failed before the change for the community-funded cases, passes after); the
authorization, routing and health tests still pass.

* Record why a stream that failed is an error in its metrics row

The exception handlers wrote their rows with no error_message, so agent_errors counted the
502 rows of empty replies but not provider or unexpected failures, and the error event's
request_id pointed at a row with no reason. The row now carries the failure's detail (the
exception class and the provider's code or status, none of the provider's message). Input
and session-limit errors (400) stay without one: they are the reader's, not the agent's.

Tested: new tests through the real Bedrock wire and the scripted model, for /ask and /chat,
reading the row back and counting agent_errors (failed before the change); the stream,
cut-off and unanswered-message test files pass.

* Guard the startup check of Bedrock defaults so it cannot stop the app

log_unserved_bedrock_defaults is a diagnostic but was called bare in the lifespan, next to
the guarded init_metrics_db call. An exception in it would have kept the app from starting.
It is now wrapped: the failure is logged with its traceback and startup goes on.

Tested: new test runs the real lifespan with the check made to raise and confirms the metrics
database is still initialized and the failure is logged (failed before); test_bedrock_deployments.py passes.

* Use _configured_default in _select_model instead of repeating it

_select_model spelled out the same community-else-platform default that _configured_default
returns (and that /config and the startup log already use). One place now decides it.
_configured_default is typed as returning a str model, which is what both branches give.

Tested: no behavior change; authorization, request-route and reasoning-effort routing tests pass.

* Log what routing finds once per request, not again for the /chat/resume probe

/chat/resume routes its request twice: a probe to see whether the result may carry images,
then the stream. The probe passed log_fallback=False, which silenced only the Bedrock-default
fallback, so the platform's OpenRouter fallback warning and the no-key error were logged twice
per request, as were a community key in use or missing and an unservable default. The flag is
now 'log' and is threaded through _resolve_provider, _platform_choice and _select_model.

Tested: /chat/resume against the real router and a local OpenRouter stand-in logs the fallback
warning once (twice before); unit tests that a probe is silent for each situation and a normal
route is not; tests/test_api passes.

* Type _effective_default's model as str

Both of its branches return a str (the configured default, or the Claude fallback), so the
| None only kept CommunityConfigResponse(default_model=...) from type checking.

Tested: annotation only; test_bedrock_deployments.py passes; ty reports one diagnostic fewer.
neuromechanist and others added 2 commits September 30, 2026 18:42
…r check, long replies, docs (#573)

* Classify an Anthropic error that arrives mid-stream and langchain-aws's unsupported stream event

A stream that fails part way has already answered 200, so the SDK raises
APIStatusError with status_code 200 and the kind only in the body
(overloaded_error, rate_limit_error, ...). It classified as unknown: logged as an
unexpected error with a traceback and sent with no retryable. It now reads the
body's error type when the status says nothing.

langchain-aws's ValueError for a stream event it has no parser for was answered as
HTTP 400 'Invalid request' with the event dump; it is the provider's, so it now
classifies as an unavailable provider failure.

Tested: tests/test_core/test_model_errors.py 74 passed; the 10 new cases fail on the
old classifier. The mid-stream errors come from the SDK's own SSE decoder.

* Server: judge a streamed reply by its last run, keep long replies, record missing usage as NULL

Final review of release 0.8.16.

- A streamed reply was judged by the text of every model run, so a sentence written
  before a tool call made an empty last run look answered and the reader got a done
  holding only that sentence. It is now judged by the last run's text, as ModelRuns
  and the non-streamed paths already do; a last run cut off with no text is the
  'ran out of room' error, not a cut-off warning.
- A model's reply was held to the 10,000 characters a person may send, so a long reply
  (above all one cut off at the output limit) was refused after it was paid for: an
  error with no done when streamed, HTTP 500 when not. Replies may be 100,000
  characters (MAX_ASSISTANT_MESSAGE_LENGTH); the streamed branch that still refuses
  one now carries the request id and writes its metrics row.
- A non-streamed request with no reported usage recorded 0 tokens and a cost of 0.0;
  it now records NULL, as a streamed one does and as the warning says.
- A non-streamed /chat answered a provider's ValueError as HTTP 400 with the
  provider's text; it is now logged with a traceback and answered as the generic 500.
- A cut-off warning's metrics summary said 'with no answer' even with an answer.
- Comments and docstrings corrected: the single-warning-element rationale (pinned
  embeds only), the SSE event lists, the Bedrock-era routing notes.

Tested: the new cases fail on the old router and pass on this one. Full suite with
the local-environment causes removed: see the pull request.

* Widget: show the error reference on a non-streamed 502, fix stale comments

A 502 for an empty or cut-off reply carries error_id and request_id in its JSON body.
A streamed error showed the reference with a copy button; the non-streamed response
path (streamingEnabled: false, or a non-SSE answer) dropped it. responseError now
carries it on the error, so the persistent banner shows the same reference.

Comments: a cut-off reply with no text and no code is an error from this server, not
a warning plus done; 'centred' to 'centered'; the SSE event list in the header now has
warning (with codes), error (error_id, request_id, retryable) and session.

Tested: frontend/test-widget-paced-streaming.js 257 passed; the new reference checks
fail on the old widget.

* Test: the Bedrock deployment log checks cannot pass when nothing is logged

The loop over the logged records had no non-empty check, so a case that should log a
community could log nothing and still pass. Both cases now assert the logged community
ids equal the ids derived from the registry.

Tested: tests/test_api/test_bedrock_deployments.py passes.

* Docs: retitle the changelog 0.8.16, add the review-round changes and a security entry, fix the fallback wording

CHANGELOG: [Unreleased] becomes [0.8.16] with a new empty [Unreleased] above it.
Entries for what the two review rounds shipped and the changelog lacked: an empty or
cut-off reply is now an error or warning (HTTP 502 when not streamed, which a client
that retries on 5xx will re-bill), classified stream failures, the unanswered message
kept in the session, missing-usage logging, the CLI and widget changes, and the metrics
rows of failed streams. A Security entry for #571 (unescaped model text in innerHTML,
present in the 0.8.15 widget; pinned embeds stay exposed until re-pinned). Entries for
this round's own fixes. The Luna fallback is described as the code does it: the
deployment's Claude default with an error logged when the Bedrock key is missing, a
warning for a caller's own key, OpenRouter or HTTP 500 with no ANTHROPIC_API_KEY.
Luna is high by default, not never at maximum; the 27 s and 48 s figures are labeled.

Also ADR 0014 and 0015, the ADR index titles, .context/api-structure.md (pointer at the
top, fallback wording), the community config comments, deploy/Dockerfile, the
bedrock_region description and two docstrings in core/config/community.py. Comments and
documentation only; no config value changed.

Tested: ruff check and format; the config and routing tests pass.

* Review follow-ups: test the streamed session-limit branch, align the widget's reply bound, one usage rule

- A test for the streamed branch that still refuses a reply over the model limit: the
  error carries the request id, one 500 row is written with an error_message, the cost
  is kept, and nothing is stored. Removing the request id or the metrics call now fails it.
- The widget's history check dropped a reply of exactly 100,000 characters, which the
  server keeps; it now accepts up to and including that length.
- A non-streamed request's row is NULL when input plus output tokens are zero, the rule
  the streamed row and ModelRuns use, not the total field.
- Docstrings: reply_problem's reply_text is the last run's text; _select_model names the
  platform's OpenRouter fallback.
- Removed a duplicate TestRetiredEnvironmentVariables from test_bedrock_routing.py
  (tests/test_api/test_config.py has it); the hermetic fixture stays.

Tested: the affected Python files (402 passed) and the widget suites.
@neuromechanist
neuromechanist merged commit b6d87ea into main Oct 1, 2026
61 checks passed
neuromechanist added a commit that referenced this pull request Oct 13, 2026
* ci: merge the two Tests workflows into one

tests.yml and test.yml were both named "Tests" and both ran Lint, the
Python suite, Frontend Tests (including the live-nemar Chrome checks)
on every pull request into and push to main. tests.yml now carries the
union: workflow_dispatch with the model input, ruff check over the
whole repository, Python 3.13 on main-bound runs, the Integration Tests
job, the Codecov token, and a pytest selection that equals the union
of the two old ones (checked by collecting both: 5,310 node ids).

The required check names Lint, Test (3.11) and Test (3.12) are
unchanged. test.yml's skip for the strip-dev-suffix commit is dropped:
it tested github.actor, which is the CI_ADMIN_TOKEN owner on that push,
so it never matched. tests/test_frontend_job_parity.py compared the
two copies of the frontend job and has nothing left to compare.

Tested: actionlint clean; uv run pytest tests/ -m "not network and
not llm" passes locally.

* ci: let documentation-only changes pass Tests

Documentation-only pull requests relied on the skip-ci marker in both
the branch commit and the title, so no workflow ran, the required Lint
and Test (3.12) never reported, and an admin had to merge them.

A new changes job classifies the pull request (its merge commit against
the base) or the push (against the previous head). When only
documentation changed, Lint and the Test legs still run and report
success under their exact names, skipping their steps except
test_embed_snippet_hygiene.py, which scans every tracked text file for
widget embed snippets. Frontend Tests, not required, skips at job
level. The required jobs skip at step level because a matrix job
skipped by a job-level if reports as "Test", not "Test (3.12)".
Anything the job cannot classify, or a failure of the job, runs
everything.

Tested: actionlint clean; the classify script run against 14 real and
synthetic pushes and merge commits gives the expected outputs.

* ci: stop re-running Tests on bot version commits

Every develop merge was followed by auto-bump-dev's "Bump version to"
commit, and every release by ensure-stable-version's strip commit; each
re-ran the whole Tests workflow (68 of 140 develop push runs in the
forensics window were bump commits) on code tested one commit earlier.

The changes job now marks a push of that commit alone, identified by
author and committer github-actions[bot], the message, and a push diff
of exactly src/version.py, so Lint and the Test legs report success
without running their steps. github.actor cannot identify these pushes:
it is the CI_ADMIN_TOKEN owner. Pull requests are never skipped, so
sync-develop's pull request, which ends in a bump commit, still runs.

Tested: actionlint clean; classify script cases for a lone bump, a lone
strip, a bump pushed with a code commit, a human version-only push and
a bump-headed pull request all give the expected outputs.

* ci: cancel superseded pull request runs

Tests, the Cloudflare preview deploys, the notebook site check, the
Worker CORS check and the preview DNS cleanup had no concurrency, so
every push to a pull request left the older runs going: release pull
request #562 collected 139 runs from its own synchronize events.

Each now groups pull request runs by workflow and pull request number
and cancels the older one. Push, schedule and dispatch runs get a group
of their own (the run id), so runs on develop and main are never
cancelled or queued. docker-build.yml already cancels its pull request
runs and keeps its own group. claude.yml is left alone: each review
comment there is a separate request, not a newer version of one.

Tested: actionlint reports no new findings on the six workflows.

* ci: give every workflow job a timeout

No job had timeout-minutes, apart from one Chrome step, so a hung job
ran to the 360-minute limit: nine Tests runs on 09-29 did (36528208246,
Test (3.11) stuck in "Run tests"), and 36802838547 and 36802842185 sat
for about 24 hours.

Each job now gets about twice its p95 duration over its recent
successful runs, rounded up, with a floor of 10 minutes. That is 10
everywhere except the Test legs, 21 (3.12 p95 10.2 min, 3.11 8.3), and
claude.yml's @claude job, 30: two successful runs are too few to
measure, and an agent session should not be cut off mid-change.

Tested: actionlint reports no new findings; every job in the 21
workflows parses with a timeout-minutes value.

* test: fail any single test after five minutes

The 09-29 hang was inside pytest: Test (3.11) of run 36528208246
printed tests/test_core/test_litellm_chat.py::TestTagsBecomeCitations::
test_a_streamed_reply PASSED at 06:05:33 and nothing more until the
6-hour cancel. The job timeout now bounds the job; this bounds the test,
so a hang fails that one test with its traceback and the run goes on.

pytest-timeout joins the dev dependency group (uv add --dev), with
timeout = 300 in [tool.pytest.ini_options]. The slowest passing tests,
tests/test_api/test_sync.py's trigger tests, take about 70 s on CI at
most (measured from six recent Test job logs) and 4 to 52 s locally.
uv 0.13.0, the version CI installs, writes the lockfile as revision 5.

Tested: uv run pytest tests/ -m "not network and not llm" passes
locally (5,295 passed, 14 skipped) with the timeout active.

* ci: deploy develop once per merge, after the bump

A develop merge built and pushed the dev image twice: once for the
merge commit, then, seconds later, for auto-bump's version commit, and
the development host (auto-update-dev.sh, every 15 minutes) could pull
either. After each release, TestPyPI also got two dev versions: the
sync merge's X.dev0, then the bump's X.dev1.

docker-build.yml and publish-testpypi.yml no longer run on a push to
develop. auto-bump-dev.yml gains a deploy job that runs after the bump
and dispatches both once: the image from the head of develop (the bump
commit), and TestPyPI for the bump commit's sha, so the image and the
package carry the version develop ends at. With no bump (skip-bump, no
.devN, a lost push race, a failed bump) it dispatches for the pushed
commit, so nothing that deployed before goes undeployed. It skips only
the bump commit's own push. publish-testpypi.yml takes a sha input and
publishes only from develop, as before.

The bump commit keeps no skip-ci marker: develop's head is a release
pull request's head commit, and GitHub skips a pull request's workflows
when its head commit carries the marker.

Tested: actionlint clean on both changed workflows (publish-testpypi.yml
keeps its 12 pre-existing shellcheck notes); tests/test_latest_tag_
policy.py passes.

* ci: build the PR image only when inputs change

docker-build.yml built and smoke-tested the image on every pull request
into develop or main, documentation and frontend-only ones included.
deploy/Dockerfile copies only src/, pyproject.toml, uv.lock and
README.md (the hed-lsp stage clones a pinned commit), so 30 of the 88
develop merges between 09-24 and 10-13 would have built an image
identical to the base.

The pull_request trigger now has a paths filter on those inputs, the
Dockerfile, .dockerignore and the workflow itself. That is safe at
trigger level because no job here is a required check. Push, tag,
release and dispatch builds are unchanged.

Tested: actionlint clean; tests/test_latest_tag_policy.py passes.

* ci: keep network tests out of docs-only runs

The docs-only path ran the whole embed hygiene file, which holds a network test that fetches jsDelivr. A jsDelivr outage would have failed every docs-only pull request. It now uses the same marker filter as the full run. Tested by running the file with the filter locally.

* ci: let the optional 3.13 leg fail alone

Test (3.13) is not a required check, but it shares a matrix with the required legs. With the default fail-fast, a 3.13-only failure cancelled Test (3.11) and Test (3.12) and blocked release pull requests. Set fail-fast to false. Tested by parsing the workflow and running actionlint.

* ci: count only listed Markdown as documentation

The classifier denied a list of code directories and let any other file under docs/, .context/ and .rules/ pass, so a future script there would skip lint. Allow only Markdown in those directories, root-level Markdown and LICENSE; any other path runs everything. Tested with 15 sample paths, including nested, renamed-type and new-directory cases.

* ci: dispatch both develop deploys before failing

Under bash -e a failed image dispatch skipped the TestPyPI dispatch. Try both and fail at the end. Also correct the comment: the build uses the head of develop when it is dispatched, not when it starts. Tested with actionlint; the dispatch itself cannot run before merge.

* ci: publish to TestPyPI only commits on develop

The ref check covered the dispatch ref but not the sha input, so a commit from another branch could publish. Require the sha to be identical to or behind develop, and say in the input description that a sha is needed to republish an older version. Tested the compare call on real commits: identical, behind and ahead.

* docs: use skip-bump for documentation merges

GitHub reads the skip-ci marker from a pull request's head commit, so a documentation merge that left it as the head of develop would make the next release pull request run no checks. Tell authors to put skip-bump in the title instead and state the cost.

* docs: fix stale test.yml and sha-tag references

test.yml was merged into tests.yml, and only the final commit of each develop merge now gets a sha image tag. Update the comments, the notebook README, the ADR sentence and the rollback instructions to match. Documentation and comments only.

This branch was previously deployed

1 inactive deployment
testpypi — 0368967b Deployed Oct 1, 2026 by neuromechanist via Publish to TestPyPI #146
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment