Nineteen community pull requests plus the fixes behind this week's
reports. The thread through most of it is reasoning models: a book that
came back as one empty chapter, a quiz that produced no questions, and a
chapter body carrying the model's own scratchpad are the same failure —
a token budget spent on hidden thinking with nothing left for the
answer, and no error to say so.
Release notes: assets/releases/ver1-6-7.md
tsconfig.node-tests.json included only tests/, while the app tsconfig
also includes types/**/*.d.ts. Nothing had noticed, because no node
test had ever pulled lib/chat-import/* into that program. The new
chat-import-codex spec does, and that code calls
FileSystemDirectoryHandle.values() — declared in
types/file-system-access.d.ts, not in the DOM lib at this TS version —
so the compile failed with TS2339 and took the whole CI job with it.
Test-harness config only; no product code. npm run test:node: 1122
passed, 0 failed.
_reap_unowned_live_turn accepts queued, running and waiting_input —
all three are rows _begin_turn_sync counts as active — but nothing
pinned the queued case, so narrowing the set back to waiting_input
alone left the whole suite green.
Cherry-picked from the PR-review session (3844aa7a); tests only.
Importing a current Codex session gave the learner a message they never
wrote — a 4KB catalogue of uninstalled plugins — and a session titled
with the first line of it (#1354, follow-up to #1327).
Codex delivers its own context to the model as `role: "user"` items.
Across the 631 rollouts on this machine that is ten distinct tags —
`environment_context`, `recommended_plugins`, `codex_internal_context`,
`skill`, `task`, `heartbeat`, `turn_aborted`, `subagent_notification`,
`codex_delegation`, `send_user_message_question_reply` — and about a
third of every user turn on disk.
Matching the tags would fix today and nothing after it: the list is the
harness's to grow, and a new one walks straight through. What the
injected turns share is a shape, not a name — each is *nothing but*
markup, one or more balanced top-level elements with no prose of the
person's own anywhere around them. So `isHarnessInjectedTurn` consumes
top-level elements and keeps the turn the moment a single character of
anything else remains.
Erring that way is not caution for its own sake, it is the common case:
an attachment turn arrives as `<image name=[Image #1]></image>` followed
by the actual question, 76 of them here, and every one is kept because
the question sits outside the element. Anything ambiguous — a same-named
nested tag, an unclosed one, an attribute holding a `>` — falls out of
the loop unmatched and is kept too. Losing a title to a block we failed
to recognise is a blemish; eating the sentence someone typed is not.
Known to under-catch, deliberately: 181 turns pair the plugin catalogue
with an injected `# AGENTS.md instructions for <path>` in plain markdown,
which has no shape to recognise and would need the literal string. Those
still import.
The legacy `event_msg` path is untouched — it carries none of this (zero
such turns in the corpus), and the tests pin the `<image>` prefix and an
unclosed tag as the two cases that must survive.
Two paths left a durable row that blocked its whole session, because
`_begin_turn_sync` counts `waiting_input` as active and refuses every
later message with "Session already has an active turn" (#1297, #1359).
The terminal write on cancellation CAS'd on `expected_status="running"`
alone. A turn parked on `ask_user` sits at `waiting_input`, and the
waiter's restore to `running` is fired through `asyncio.shield` — so it
races that write and loses about as often as it wins. When it lost, nothing
terminal was written, no `done` event went out, and the row stayed
`waiting_input` forever: pressing Stop on a question was enough, no restart
needed. Both states are live and owned by the same execution, so both are
valid predecessors of its terminal state; the fencing token is still what
proves ownership.
`cancel_turn` also returned False when nothing held the lease, so Stop on a
card whose worker was gone was reported as a refusal the UI could not act on
while the row kept blocking the session. It now reaps, for the same reason
`submit_user_reply` does — and the reaper is widened to every live status
and renamed, since `queued` and `running` orphans block a session exactly
as `waiting_input` ones do.
NOT covered, deliberately: nothing sweeps rows left behind by a process that
died, because `MemoryCoordinator._known_turns` is per-process and
`list_expired_turn_ids()` is empty after a restart. That needs an age
threshold to avoid reaping a turn between its INSERT and its first lease
renewal, which is not a change to make unattended. This fixes the path that
*creates* the zombies; pre-existing rows still need that sweep.
(cherry picked from commit 5f040dbc9fc8be02f2281cf91c25e86f5991fa92)
#1366 gave the book's reader-facing blocks a way to ask for no thinking
at all, and the merge in 4e2f0885 now carries that explicit effort into
the retry as well — so a family that answers HTTP 400 to
reasoning_effort="none" (#734: gemini-3, gemini-2.5-pro) would fail
twice per block instead of once.
The narrowing table already existed, but only inside
default_reasoning_effort_for, which is consulted when the caller says
nothing. A caller that names "none" itself skipped it. Names the rule as
thinking_off_effort_for and routes an explicit "none" through it too,
next to _MINIMAL_NOT_OFF_PATTERNS so extending one table still prompts a
look at the other.
Verified: gemini-3-pro / gemini-2.5-pro resolve to minimal;
gemini-2.5-flash and gpt-4o keep none.
Patch authored in the PR-review session.
The follow-up to #1357 moved ResearchPipeline's defaults to a 240s
ceiling with retries off, but `_MAIN_YAML_RUNTIME_DEFAULTS` still held
60s / 3 retries. That table is the fallback used when a research
settings payload is written, so a user who merely opened research
settings and saved — without touching either field — persisted 60/3 into
main.yaml and the pipeline default became unreachable from then on.
Same shape as #1316, where a section missing from the config map meant a
4096 token budget no user could raise. A default that a layer above
silently overwrites is not a default, so pin the invariant in a test
rather than leaving the two numbers to drift again.
`crypto.getRandomValues` is not gated on a secure context — only
`randomUUID` is — so it is the right fallback on a plain-HTTP deployment,
and the `Math.random` tail is left only for a runtime with no Web Crypto.
The bare `globalThis.crypto.randomUUID()` this fixes had a twin at
`contracts/parse/turn-command.ts`, which throws in exactly the same
deployment. Both now call one exported `newCommandId`, living beside the
`command_id` field it fills rather than in the transport that happened to
notice first.
(cherry picked from commit 70333c900034d383500ca92e294b23445394068f)
The clamp read `min(clampedTop, rowCenter - lowerMargin)`, and
`rowCenter - 0.75h` is always the smaller of the two, so every cue
subtracted three quarters of a viewport from the centring offset — putting
the active row below the bottom edge, or pinned at the top for early cues.
The intent was to move only when the row leaves the middle 50%.
The arithmetic *is* the behaviour, so it moves to a pure
`transcriptFollowScrollTop` with the six cases pinned: inside the band
(no scroll at all, so the list stops creeping under the reader), above it,
below it, first cue, last cue, and a list too short to scroll.
(cherry picked from commit 0e51f652024d755460ea122447548d40e9285c16)
60s cancels research work that was going to finish — one rag call against
a LightRAG or GraphRAG index makes its own LLM calls before returning, and
search-then-fetch waits on someone else's site — and each of the three
retries then pays the full timeout again. 240s is the ceiling
geogebra_analysis already uses for the same reason; retries default to 0 so
only a caller who knows its tools are flaky, not slow, pays for a second
attempt. Both remain configurable under researching.
Pins the pair in a test: the policy tests pass whatever they configure, so
nothing held these two numbers.
(cherry picked from commit 389fe3f0daf1abb4eddc87be84485d47982b84a3)
`modalities_attempts` is never empty, so `resp` is always bound when the
loop ends — the second refusal stays in it. `last_404`, the `resp is None`
guard and the `assert` were three ways of restating that, and an `assert`
in a request path disappears under `python -O`.
(cherry picked from commit f2dfe4550d52c80d5bee1502a281eafcfaa491d4)
Resolves two collisions with the fixes committed locally tonight:
* book/blocks/_llm_writer.py — #1366 threaded a reasoning_effort
through llm_json while 5ac8e2c9 replaced this file's private
_json_has_expected with the shared json_payload_is_usable.
Taking either side alone breaks: origin/dev's calls a helper that no
longer exists, ours drops the caller's explicit effort. Kept the shared
helper and the threading, and the retry now reuses an explicitly given
effort so a round deliberately run without thinking cannot re-enable it.
* runtime/agentic/tool_dispatch.py — #1357 added tool_timeout /
tool_max_retries to execute_tool_call in the same parameter list where
4e816d79 renamed unknown_error_message_factory (tool) to
tool_error_message_factory (tool, error). Both are needed: the
dispatcher already passes the timeout pair through, and every call site
in the tree now uses the renamed factory.
* fix(llm): survive api_key key pools in the config resolver
A catalog profile configured with multiple keys (api_key as a JSON array)
crashes get_llm_config(): the placeholder check in
_get_llm_config_from_resolver does set membership on the raw list, which
raises TypeError: unhashable type: 'list' — taking down every LLM call in
the process, not just multi-key deployments.
This is a regression of #962's behavior: cc23cbe3a (#863) added a second
placeholder check in the resolver without wrapping the key through
primary_api_key(), which #962 introduced for exactly this reason. The
provider layer (OpenAICompatProvider) already accepts str | list[str] and
rotates via KeyPool — only the resolver entry was left behind.
Fix: unwrap through primary_api_key() for the placeholder check and pass
the full list through to the provider so KeyPool keeps rotating.
Tests: 4-key array reaches KeyPool intact; placeholder check uses the
primary key; single-key profiles behave exactly as before.
* style: ruff format
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: interia <interia@interiadeMac-mini.local>
Co-authored-by: Claude <noreply@anthropic.com>
* fix(geogebra): repair image analysis that crashed before any model call
Every invocation of the ``geogebra_analysis`` tool died with a TypeError
before reaching a model: ``_call_vision_llm`` passed a ``verbose=False``
kwarg that ``BaseAgent.stream_llm`` does not accept (the signature has no
``verbose`` parameter and no ``**kwargs`` fallback). Image understanding —
the only path that turns a problem figure into GeoGebra commands — was
therefore broken end to end, in both chat and deep_solve.
Two repairs in the vision solver agent:
* drop the nonexistent ``verbose=`` kwarg so the call reaches the model;
* make ``_extract_json`` tolerate what reasoning vision models actually
return: a ``<think>`` preamble (e.g. Qwen3-VL-*-Thinking), prose after
the JSON object, multiple fenced blocks (the last one wins), and bare
tail JSON. The comment and trailing-comma tolerance of the original
parser is preserved.
Regression coverage: parametrized ``_extract_json`` cases for the shapes
above, plus a test asserting ``_call_vision_llm`` forwards no ``verbose``
kwarg while still building the multimodal ``image_url`` message.
* fix(geogebra): bound a stalled vision analysis with a 240s timeout
An unbounded ``await agent.process(...)`` lets a stalled provider hang the
whole turn. Reasoning VL models legitimately take minutes on hard figures,
so the bound is generous (240s): it only converts a silent hang into a
loud, actionable failure ("retry, or describe the figure in text") instead
of leaving the learner staring at an empty response.
`stream()`'s runner assigned `saw_output` without declaring it nonlocal,
so the name was local to the runner. A provider that returned
`finish_reason="error"` after streaming deltas crashed the runner with
UnboundLocalError, and one that returned it before any delta had its
operator message ("Error calling LLM: ...") enqueued as the model's
answer with the error swallowed.
Declare the nonlocal, and skip the post-stream content synthesis for
error-shaped responses so the existing guard raises them as LLMAPIError.
Text already delivered is still kept, as before.
_coordinate_execution discarded the bool submit_user_reply returns, so a
reply that arrives after the turn's local queue is gone gets a false ACK
and the turn sits at waiting_input forever with no trace of why. Capture
the return value and log a warning with the command id, turn id, lease
owner and persisted status instead.
Fixes#1297
The SettingsReadinessPanel component returned null whenever its
`enabled` prop was false. The prop is wired to catalogEditable in
SettingsOverview, which means any signed-in user without edit rights on
the model catalog — every learner account, every assigned role on a
multi-user install — saw nothing where the rest of the team saw
"what is ready, what is broken, what is folded away".
Read-only users still benefit from seeing readiness:
- The data is informational, not actionable.
- They have the same LLM and same parser behind the scenes, and
they deserve the same "endpoint is unreachable / misconfigured"
signal an editor sees, so they can ask an admin to fix it.
Keep `enabled` as the gate on user-facing controls only:
- The manual refresh button is disabled when !enabled.
- The "Open" link on each attention row is hidden when !enabled.
This also unblocks the Playwright audit at
tests/e2e/settings-navigation.audit.ts, which mocks
/api/settings/readiness and expects the section to render the mocked
matrix. On dev/CI the catalogEditable path is not reached (no real
backend), so the panel returned null and the audit failed. The same
gate was masking this failure on dev: the previous CI step
(npm run perf:check) exited non-zero before the audit ran, so dev has
been red here since PR #1201 was merged.
Verified locally: typecheck passes (only the unrelated missing-node-
types warning); existing settings-readiness Node tests still pass.
Ask for a quiz with a reasoning model and sometimes one question arrives,
sometimes none, with nothing in the UI and one `LLM returned empty
response` in the log (#1318). Reproduced on both a 35B llama.cpp build
and a 27B vLLM one, so it is not a model or a backend.
The plan step is a single labeled call that must emit a whole JSON object
of templates, and it had the tightest budget in the file — 2000, below
even the 4096 the `question` capability ships with. A reasoning model
pays for its hidden tokens out of that same allowance, so on a rich
exploration trace it can spend the lot before the label. `PLAN_MAX_TOKENS`
is now 6000: the plan itself is a few hundred tokens and the rest is room
to think in.
A bigger number is not the fix, because no number is large enough for
every model. The fix is that the step now says what happened.
`run_labeled_step` strips the scratchpad on the way out — deliberately,
so a truncated one never reaches a reader — which left "starved
mid-thought" and "the model genuinely said nothing" as the same empty
string. `_parse_plan` read it as a plan of zero templates and phase 3,
which iterates them, emitted no questions and no error.
`LabeledStepResult.reasoning_only` separates them: no label ever arrived,
no text, no tool calls, and the model demonstrably did reason (inline
`<think>` or the provider's own channel). Tool calls disqualify it — that
round acted, it just did not narrate, and re-asking would repeat the
call. The plan step spends the signal on one more attempt with thinking
turned down, which is the same escape hatch Book already uses; its
`RETRY_REASONING_EFFORT` moved to `services/llm/reasoning_params` so the
choice of level, and why it is "low" and not "minimal", is stated once.
Every labeled step in the codebase now carries the flag, so `EXPLORE`,
`QUIZ` and `REPAIR` — which share the same exposure on smaller budgets —
are at least diagnosable. Whether an under-filled plan should warn or
fail is a separate question and is deliberately left where it was.
Stop the Ollama a vector KB embeds against, ask a question, and the model
is told "An unknown error occurred while executing rag." The adapter had
already written the answer — `Cannot connect to Ollama at
http://localhost:11434. Make sure Ollama is running. Start it with:
ollama serve` — and the dispatcher was holding it (#1356).
`unknown_error_message_factory` took the tool name and nothing else, so
no caller could have done better. Four capabilities each wrote their own
message from that one argument and three of them called the result
unknown; the fourth, pageindex, restated the dispatcher's own default
minus the cause. The name was the bug: it presumed a cause the runtime
always had.
It is now `ToolErrorMessageFactory`, `(tool, cause) -> str`, and the key
plus the English wording live once in `tool_error_message_factory`, which
each capability wraps around its own `_t`. Capabilities keep their
translations and can no longer keep the cause out of them. pageindex
passes nothing and takes the default. A bundle predating the new
`notices.tool_error` key falls back to English rather than to silence
about what went wrong, which is the reason the fallback carries the cause
too.
This is the same shape as read_skill answering "skill not found" when the
skill resolved and only the file was missing (#1347): a failure the
caller cannot see has no way out, and the model spends its rounds
inventing one.
The regression test is the reporter's turn — a `rag` call raising the
real adapter error — and asserts the endpoint and the remediation reach
the role=tool message.
A maths or physics tutoring turn reaches the learner with its LaTeX
intact: a Bellman question shows `$G_t = R_{t+1} + \gamma G_{t+1}$`, a
derivation shows `$\Delta = 4 - 20 = -16 < 0$`, and a bolded cue shows
its asterisks. Three separate surfaces, one cause each.
`MarkdownRenderer` refused the rich renderer whenever the variant was
`trace`, so no trace bubble could ever reach KaTeX — and
`RichMarkdownRenderer`'s entire `isTrace` branch, written for exactly
this, was unreachable code. Rich is chosen by what the content contains,
not by which surface shows it; a trace bubble with no math still takes
the cheap path, which is what that exclusion was really protecting.
The mastery question card and the ask_user card interpolated plain
strings. They are also short, and they sit inside `<button>` and
one-line rows, so the block renderer is the wrong tool: a `<p>` is not
valid there and brings block spacing with it. `InlineMarkdown` emits
phrasing content only and loads KaTeX at all only when the string has
something to render, so an ordinary question costs nothing. It now
renders the mastery stem, its options and its verdict explanation, and
the ask_user intro, stem, option labels and option descriptions.
Escaped-unicode decoding moved inside it, so callers no longer choose
between decoding a string and rendering it.
Pointing DeepTutor at a local Ollama and getting it wrong produces
"Unable to reach the model provider. Please retry." in the UI and a bare
`httpcore.ConnectError: All connection attempts failed` in the log.
Neither says what to do, and the two ways this fails need opposite
fixes: nothing is listening on the address, or DeepTutor is inside a
container where `localhost` is the container rather than the machine
serving the model.
`unreachable_endpoint_hint` names which. It stays silent for a cloud
endpoint — there "please retry" really is the whole story — and for a
loopback address inside a container it points at
`host.docker.internal`, the answer CONTAINERIZATION.md already
documents but that nobody reads at the moment they need it. An address
that is already the host gateway gets the "start the server" advice
instead, not advice to use the gateway it is using.
Appended only when the round produced no output: an interrupted answer
is a different failure and the endpoint is demonstrably reachable.
A thinking model's provider rejects a history that lost the reasoning
which produced an earlier assistant turn: "the `reasoning_content` in
the thinking mode must be passed back to the API". Reported against
deepseek-v4-flash, where it surfaced as `quiz generation failed`.
Replay was already implemented — twice, inconsistently. Inside one turn
the loop writes `reasoning_content` onto the assistant message directly
and the key is allow-listed, so every model keeps it. Across turns the
field is rebuilt from the private `_provider_response_state`, and that
path required `"deepseek"` to appear in the model name.
A model name is not how a provider announces its dialect. Volcengine Ark
takes an endpoint id (`ep-…`) as the model, and Doubao, GLM, Qwen and
Kimi thinking models all speak this field under their own names. Every
one of them worked for the length of a turn and then failed the moment a
new turn replayed history — the asymmetry is the bug.
The gate is now the state itself. Only a provider that *sent*
`reasoning_content` (or `reasoning`) can have put it there, so replaying
it is symmetric rather than additive: a model that never reasons still
carries no such field, which is what the second test pins. The `model`
argument to `_sanitize_messages` existed only for the old check and is
gone.
A book built with a reasoning model arrives as a single "Overview"
chapter, or with the right chapter count and every learning objective
and summary empty (#1316). Two independent faults compose into that.
`get_agent_params` maps a module name to a section of agents.yaml, and
`book` was not in the map — so the function returned the source-level
`global_defaults` of 4096 *before* ever opening the file. That budget
was therefore not the shipped default and not overridable: adding a
`capabilities.book` block did nothing, and only editing the source could
change it. It is now mapped, seeded at 12000 in DEFAULT_AGENTS_SETTINGS
(so a stale agents.yaml still gets it), and honoured from the yaml.
12000 rather than a larger figure matches `research`, the closest
analogue, and keeps the request under the output cap of providers that
enforce one.
The budget is the trigger, not the fault. A reasoning model pays for its
hidden tokens out of the same `max_tokens` as its answer, so on a large
prompt asking for a whole JSON object it can spend the lot and emit
nothing. The provider does not raise — it returns a truncated body, or
none — and `parse_json_response` hands back the caller's fallback, which
in `SpineSynthesizer._materialise` is one placeholder chapter. Where the
budget ran out *mid*-object, json-repair closes the fragment and the
caller gets chapters whose objectives never arrived: the same failure
wearing a different face.
`blocks/_llm_writer.llm_json` already knew the escape hatch — ask again
with thinking turned down — but only block generators went through it.
The four pipeline agents each parsed their own response and had no retry
at all. `book/json_retry.py` is now the one place that rule lives, and
ideation, both source-explorer calls, all three spine rounds and the
page planner go through it; `llm_json` shares its predicate so the two
cannot drift. Each caller names the key that proves the payload arrived,
which is what lets a repaired-but-gutted object trigger the retry rather
than settle the stage.
`BaseAgent.call_llm` / `stream_llm` gained the `reasoning_effort`
parameter this needs; it was already the shape `llm_text` used.
Ship the v1.6.5 feedback sweep: answers that could not submit now
arrive, a copy button reports what actually happened, partners can use
connected knowledge bases, Codex sign-in finishes inside Docker, and the
home route is 100KB lighter.
Release notes: assets/releases/ver1-6-6.md
One partner serving three study groups plus DMs rendered as a flat list
where every row looked like a private chat: the only label is the
opening message, which in a group is one student's question (#1229). The
data was never lost — sessions are already one file per chat — it just
never reached the list.
The channels state the kind of conversation on the inbound event and
DeepTutor was dropping it: Feishu sends ``chat_type`` ("group" / "p2p"),
Slack and Mattermost send ``channel_type``. Delivery is the only moment
this is known for certain, so the turn records it, and the summary reads
it back. No prefix sniffing, no lookup on the read path, and nothing has
to import a channel to render a list.
``conversation_scope`` is the single place those three vocabularies
become the two words a reader cares about. A channel that says nothing —
or says something new — yields no label at all, and the row renders as
it always did; a list that guesses is worse than one that stays quiet.
Sessions written before this carry no origin and are likewise unlabelled
rather than marked "unknown".
This is the distinction the report called the minimal useful fix.
Resolving a Feishu group's *name* through the chats API, which is what
it asked for first, is left out on purpose: it needs a call and a cache
I cannot exercise against a real tenant here.
The regenerated contract picks up ``/api/knowledge-bases/delete`` as
well — the committed schema was already behind by that route before this
change, and the file is generated, so it comes back whole.
The provider redirects the browser to a loopback listener. Under Docker
that listener runs inside the container and the standard compose file
publishes only the Web and API ports, so the browser lands on a page it
cannot load while the sign-in waits until it expires. The card treated
localhost as native local execution and offered nothing else: the remote
guidance was gated behind a non-loopback hostname, so the one deployment
that most needs a way back in was the one that never saw it (#1252).
The browser can read that address even when this process cannot receive
it, so pasting it back is the recovery path. It goes to a new
authenticated endpoint on the Web origin, which resolves the caller's
*own* pending operation rather than scanning every login in the process
— the loopback route has to identify itself by OAuth state because it
arrives without a session, and this one does not.
``parse_oauth_callback_url`` is where the address is judged, once: it
must be this login's registered redirect URI down to scheme, host, port
and path, and a repeated OAuth parameter is ambiguous rather than
untidy, so it is refused instead of resolved to one of the two. The
string is parsed and dropped — never fetched, never stored, never
echoed. Past the parse it is ``receive_callback``, so the state check,
PKCE, the registered redirect URI and owner binding are the existing
ones rather than a second implementation of them.
The form now appears whenever a login is waiting, local or remote; the
SSH command stays remote-only, because that advice is.
A partner web chat runs as a synthetic user, so ``workspace_present``
writes its manifest under ``data/partners/<id>/workspace``. The download
route resolved the item against the caller's own bindings only,
``binding_by_id`` refused a workspace no human account has registered,
and the attachment the transcript was still offering 404'd on click
(#1267).
``/files/outputs`` already reaches into the caller's visible partner
workspaces for the same reason (#1012); this is the other artifact URL
shape and it had been left behind. Reading the two routers side by side
was what showed the asymmetry.
The two differ in one respect, and deliberately: an output is addressed
by a relative path that several partners could each hold, so that
endpoint serves only a unique match. A workspace id is derived from the
owning user id together with the physical root and re-derived before a
stored row is trusted, so a hit inside a partner scope is that
partner's by construction and the first one is the answer.
The reported issue named three further causes — an unmounted router and
two rejected path shapes. None of them hold: both routers are mounted,
and the partner output fallback has been there since #1012.
#1227 is #938 again, one model id later. ``k3`` had an exact-match rule
and its own entry in the vendor-detection list; ``k3-256k`` shipped
afterwards, matched neither, and every call to it came back HTTP 400
"invalid temperature: only 1 is allowed for this model". Adding a third
literal fixes today's id and leaves the next one — ``k3-1m``,
``k3-turbo`` — to fail the same way and be reported a third time.
So state the family instead of enumerating its members.
``_matches_model_family`` is the one place that decides what ``k3``
covers (the bare id, or the id plus a dash suffix), and both callers ask
it: the request-parameter overrides, and ``find_by_model``, which is
what carries the limit when the user picked a generic OpenAI binding.
The ``=exact`` pattern kind had no other user, so it is gone rather than
left as a second way to spell almost the same thing.
The replaced test pinned ``k3-256kx`` as a non-match, which was the old
mechanism showing through rather than a behaviour anyone wants; the
short ids the rule actually has to exclude — ``sk3``, ``k30``, ``k3x``
— still do not match.
DeepSeek's thinking models reject a continuation whose history has lost the
previous assistant turn's reasoning:
The `reasoning_content` in the thinking mode must be passed back to the API.
Chat's loop has replayed it since #1058. The shared `runtime/agentic` loop —
the one quiz, research, PageIndex and explore_context all run on — never
did. `LabeledStepResult` had no field for it; the stream reader pulled
`reasoning_content` off each delta, pushed it to the trace UI for display,
and dropped it. All three assistant rebuild sites therefore emitted
reasoning-less turns. Round one cannot fail (system + user only); round two
always did, which is why this reads as "quiz generation failed".
The message builder's own docstring said as much: "The provider has always
known how to read this field off a message — nothing ever wrote it."
v1.6.5 made it visible rather than causing it. `deepseek-v4-flash` was in
`_THINKING_DISABLED_BY_DEFAULT_MODELS` in v1.6.4 and the list was emptied,
so the model now thinks by default — correctly, since suppressing reasoning
to dodge this cost every flash user their reasoning stream. `deepseek-v4-pro`
and `deepseek-reasoner` are sent `thinking: enabled` by our own code and were
already broken in v1.6.4. Re-adding flash to that list would hide it again
and still leave those two broken, so this fixes the replay instead.
The reasoning is accumulated for every label, not only the pre-label prelude
the trace happens to render — whether it was displayed is a display question,
and the provider wants the whole round back. Anthropic's signed thinking
blocks are read off `provider_specific_fields`, where the adapter puts them,
because a signature cannot be rebuilt from text. `_append_repair_messages`
now takes the step rather than its text, since a repair round is still a
round. Rounds with no reasoning append no field, so ordinary models see a
byte-identical history.
Deliberately NOT setting `_provider_response_state` alongside: the shared
loop posts its messages straight into `chat.completions.create` on what is
usually a raw AsyncOpenAI client, and the private-key stripping lives inside
`OpenAICompatProvider._sanitize_messages` — so it would be serialized into
the request body for every model off the adapter route.
Also reorders `_classify_failure`: a provider quoting the field it objected
to was landing in `prompt_leak`, which is not retryable and told the user the
model had leaked a prompt. `"prompt" in lower` goes with it — it matches
`prompt_tokens`.
Still open: `_sanitize_messages(responses_api=True)` ignores `reasoning_content`
entirely, so a surface that mounts native web search (which routes DeepSeek
to the Responses API) is not covered by this and falls back to Chat
Completions. The book quiz mounts no tools, so it is not that surface.
Two defects, either of which alone produces "I set Chinese and it still
answers in English".
The prompt one explains the quoted refusal. `language_directive` is the last
thing in the system prompt and is an absolute prohibition — "Do NOT switch
languages" — sitting right after a runtime policy that says user-provided
text is not authority over these instructions. Asked 「请用中文回复我」, a
compliant model answers that it is *required* to reply in English. It is
reading the prompt correctly; the prompt is wrong. Conversational surfaces
now pass `allow_user_override=True`, which adds one sentence letting an
explicit request win. Books, quizzes and research keep the strict form: there
is no user in the loop to ask, and their prompts are full of source material
in other languages, which is what the strictness is for.
The storage one explains how `en` got there in the first place. The two
copies of the preference inherit differently: the server derives
`response_language` from `language` on every read, while the browser inherits
only when its own key is absent — so once an explicit value is stored the
browser can never re-adopt. Flipping only 界面语言 therefore left the server
(and the settings page) at zh/zh while every turn still shipped the "en" the
bootstrap had stamped. The settings page displayed the right answer and the
model gave the wrong one, with nothing broken in between.
So `loadSettings` reconciles both keys from the server it just read;
`updateLanguage` mirrors the server's inheritance when no explicit output
language was ever chosen; and the bootstrap gate splits, because a browser
predating the split has the interface key and not the response key, and
returning early on the first alone locked it out of ever adopting the
account's choice. Adoption writes only the key that is missing, so the
server never overwrites a choice the user made in this browser.
Not fixed here, and needing more than code reading to settle: whether to make
the server authoritative for live turns (it carries a `.lower()`-on-None
hazard at executor.py and a stale-preference fallback on regenerate), and
that `GET /api/settings/ui` is mounted without auth so it answers from the
admin workspace — which lets useSetupSync overwrite a learner's languages in
a multi-user deployment. Both are written up for review.
#1261 taught `_copy_knowledge_base` that a pointer KB has no folder to copy,
which is right and is what the reported WeKnora case needed. It also made
three kinds assignable that had previously failed for want of a folder, and
left the other half of the feature unbuilt.
Obsidian, MarginNote and subagent KBs are each driven by an *exclusive*
`KnowledgeCapability`: when one is in a turn's KB selection it replaces the
entire tool surface. A partner passes ALL of its knowledge bases as that
selection on every turn, so a single assigned vault would silently seize
every partner turn, and a `subagent` entry with `agent_kind: partner` would
let a partner consult another partner — or itself. They are refused now, by
the set that already names them (`NON_RETRIEVABLE_KB_TYPES`), with a message
that says why instead of a bare FileNotFoundError.
The rest is the half that made a successful assignment look like a failed
one. `list_assets` scanned directories, so a pointer KB was invisible in the
partner's library — and therefore never in `excluded`, so the picker kept
offering it and the user kept assigning it to no visible effect.
`remove_asset` returned False when the folder was missing, which the router
turns into a 404, so it could not be un-assigned either. Both now treat the
folder and the config row as independent, because for a pointer KB only the
row exists.
The two existing connected-KB tests used `obsidian` as their sample, which
this change refuses; they use `weknora` now — the kind actually reported, and
one a partner may legitimately hold.
Selecting text and pressing 翻译成中文 did nothing at all — no request, no
spinner, no error. Two components were fighting over one piece of state and
the toolbar lost.
`AnnotationPopover` implements outside-dismiss with a document-level,
CAPTURE-phase `pointerdown` listener, and `onDismiss` was
`() => setSelection(null)`. The toolbar is a sibling far outside the
popover's ref, so pressing one of its buttons ran: pointerdown captured at
`document` → selection cleared → React flushes at the microtask checkpoint
between `pointerdown` and `mousedown` → the button re-renders `disabled`,
because the four selection-gated actions declare `requires: ["selection"]` →
and a disabled control is sent none of the rest of the activation sequence.
The click never happened.
It is not only translation: 引导我, 翻译成英文, 翻译成中文 and 解释词汇 are
all selection-gated and all equally unreachable, in every render mode. The
two the user did not report broken — 测一测 and 朗读 — are exactly the two
with no selection gate. Nor is it new in v1.6.5: the popover's listener dates
to v1.5.14 and the toolbar to v1.6.0, so these actions have never been
clickable. Escape routed to the same handler, so there was no way around it.
So "there is a selection" and "the popover is open" become two states. The
mount condition has to move with it — gating on `selection` alone would leave
Escape and outside-click unable to close the popover at all.
Two more that would have bitten immediately afterwards. The bar sent the
viewport locator while the selection carried its own, and the server verifies
the quote against the text of the unit it is told about — so the first
working click would have been a 400. And `busy` was a single global key, so
one action disabled all six for up to the 30s server timeout, wearing the
same dead 50%-opacity look as the bug.
The result-reset effect is split in two: a result is keyed on the material
(scrolling one page used to erase a card being read), while speech keeps both
keys, because it must stop the moment the reader navigates away.
The regression test mounts the reader and clicks the real button. Nothing
could have caught this before: the unit test is regex-over-source, and all
three Playwright audits that drive the reader stub /api/reading/extensions to
[], which makes the toolbar render nothing at all.
Every tool call in a round has its arguments bound before any of them runs.
`rebinding_tools` is how a capability says "this call repoints the turn, so
run it first and re-bind the rest against the new target" — and mastery
declared two of the three tools that do that. `mastery_mode` was missing,
even though `augment_kwargs` hands it a `_bind_active_mode` binder a few
lines below the declaration.
So in a round holding both, `mastery_mode` landed in the concurrent batch and
`mastery_quiz` kept the mode bound before the switch. Every mode-gated tool
reads `_mastery_session_mode` off that bind, so the quiz was refused for
being in `outline` — in the very round that left `outline`. The refusal then
told the model to "call mastery_mode with mode='study' first", in a round
where `mastery_mode` had already returned `status: switched`.
That round is not a corner case: the prompt asks for it twice ("切完在同一轮
把事做完"), and it is what "继续学" at the end of an outline sitting produces.
The visible result is one of the shapes behind "it asked a question and then
answered it": the tutor streams the lead-in, the card never appears because
the call was refused, and the turn carries on.
`mastery_mode` and mode.py are both new in v1.6.5, so this path is new too.
The other routes to a self-answered question are separate and still open —
mastery declares no `tool_round_output_policy` and does not buffer, so the
posing round's own prose is published unexamined, and `mastery_grade` will
grade an interaction still AWAITING. Both need more than a declaration.