Replace no longer reuses positional IDs for unrelated waypoints, invalid
questions can be voided or re-keyed, and defer advances the route without
faking mastery.
Fixes#1527
Co-authored-by: Cursor <cursoragent@cursor.com>
Ship folder-based workspaces and data migration, daily practice, redesigned
provider and model settings, and streaming conversation improvements.
Synchronize README translations and document the archive/permanent-delete
upgrade behavior in assets/releases/ver1-6-9.md.
Reduce initial JavaScript by deduplicating English resources and loading
animation features after hydration. Keep the existing route size budgets.
Update regression fixtures and browser audits for scoped URLs and the new
settings and learning interfaces.
Mastery grade sync read progress.learning_evidence, which does not exist on origin/dev and crashed every grade path before the question bank upsert.
Co-authored-by: Cursor <cursoragent@cursor.com>
Route Mastery, Book, and Immersive Reading attempts through one review record so reading quizzes are server-graded, retryable, and show the learner's pick next to the reference answer.
Co-authored-by: Cursor <cursoragent@cursor.com>
The session layer held both the decision ("is this page worth rendering?") and
the injection, and the reading capability had no way to ask the same question
without importing session internals. The predicate and the render record now
live in deeptutor/reading/page_render.py, the session helpers delegate to it,
and the viewport seed says when a rendered page is attached — a model told the
attached image is the page it is being asked about reads it instead of
guessing. With no render the seed is byte-for-byte what it was.
Stored captions do nothing by themselves, so both text paths now show them.
read_material's embedded-image list gains the description after each file
name, which is what lets a question about another page — or another deck —
be answered from figures the model never received. The reading viewport seed
adds one compact line for the open page, so a text-only model still learns
what its figures show when image input is unavailable.
When nothing is captioned the output is byte-for-byte the previous text
(asserted by test, including the store-raising path); the rendering moved to
media_notes.py to keep tools.py under its size ceiling (763 -> 728 lines).
`MarginNoteStore._connect()` handed back a raw connection that every call
site used as `with self._connect() as conn:`. A connection's own context
manager commits or rolls back but never closes, so each call left the
database file open until the garbage collector reached the connection.
On Windows an open file cannot be removed. Deleting a MarginNote KB could
then fail to remove its store (only a warning is logged), and connecting a
library under the same name reopened that store, so devices paired with
the deleted library were accepted again.
Make `_connect()` a context manager that keeps the transaction and closes
the connection, the same shape the session, reading and file-library
stores already use. The call sites are unchanged. A new test checks that
every connection the store opens is closed, so the regression fails on any
platform, not only where the existing KB deletion test does.
Two surfaces reported quiz accuracy as if it were progress toward a gate that
never reads it.
`mastery_assess` aimed at a quantitative objective is refused outright, naming
the tools that do apply. The mirror direction was silent: posing a question at
a concept objective registered it like any other, so a tutor could work an
objective its questions cannot open and never be told. That direction stays
allowed — a question is a fair way to probe a concept before teaching it — but
it now says what grading the answer will and will not do.
The objective detail panel drew `mastery` as a progress bar for every gate.
On a qualitative one that is quiz accuracy, so an objective could show a full
bar next to an outline dot that was correctly still hollow. A boolean gate now
reads all-or-nothing, and says plainly that practice questions are not what
opens it.
A concept or design objective clears on `mastery_assess` alone: quiz accuracy
lands in `mastery_levels`, which the qualitative gate never reads. Grading a
correct answer on one of those objectives nevertheless told the tutor to teach
the gap and pose the next question with `mastery_quiz` — an instruction to
loop forever on an objective no question can open. The conversation then
narrates progress it never recorded, while the study screen's outline rail,
reading the aggregate correctly, never moves. That mismatch is what learners
report as "the outline doesn't refresh".
The reading the tutor had to work from could not have corrected it either: a
qualitative objective answered right reports mastery 1.0 against threshold
1.0 with `mastered` false, and `next` is the path-wide cursor, so it often
names some other objective entirely.
Grading now branches on the gate it just consulted — pointing at
`mastery_assess` for qualitative objectives and leaving the quantitative
advice untouched — and reports which gate the mastery number was read
against.
Clicking "start review" opened a session whose first reply was a card
offering to start a session on that same topic. Clicking it opened another,
which offered the card again — one conversation per click, all on one topic,
some bound to no topic at all (#1412). Those conversations begin with nothing
to quiz against, so they answer in prose; that is the other half of the same
report (#1411).
The generator is a premise the tool states as fact. `mastery_new_session`
stays mounted inside a mastery session on purpose — sending the learner to a
*different* topic mid-course is a real thing to want — and its hand-off
instruction tells the model not to tutor the topic here, because "the mastery
tutor picks up on the other side". Inside that topic's own session there is no
other side, and nothing in the tool's result said so, so the model kept
proposing the trip it was already on.
The turn knows which topic it is tutoring; the tool did not. Binding it the
way the mastery tools already get `_mastery_path_id` lets the tool answer for
itself: a hand-off aimed at the topic this conversation *is* gets refused, with
the instruction to teach the lesson here. A hand-off to any other topic is
untouched, and so is `mastery_open_session` — returning to an older
conversation on the same topic is not a loop.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A capability that makes several different LLM calls cannot be described
by one max_tokens: the step emitting a whole JSON plan and the step
writing one paragraph need different room. `chat` has said so since it
grew `exploring`/`responding`. `question` and `research` said the same
thing in module constants instead, where no user could reach them.
The cost of that was not theoretical. `capabilities.question.max_tokens`
governed exactly one of question's six LLM calls — the follow-up agent —
while the pipeline's five steps used constants that ignored it. The plan
step's constant sat below the capability's own ceiling, which is how
#1318 shipped a step that could spend its whole allowance thinking and
emit zero templates without an error. `EXPLORE_FINISH_MAX_TOKENS` had
been dead since it was written.
Generalises the seam that already worked rather than adding a parallel
one: `get_chat_params` becomes `get_capability_params(capability)` over a
table of per-stage defaults, and `question`, `research` and
`explore_context` get tables of their own holding the numbers they
already ran on. The pipelines resolve once in `__init__` beside the
budget they already cached. Unknown keys are dropped, so a misspelled
stage cannot become a silent no-op that reads like a setting.
The rule this establishes, stated in the tables: **agents.yaml owns every
LLM budget** (temperature, max_tokens, per stage); **main.yaml owns
runtime behaviour** (iteration caps, timeouts, retry policy, modes). A
budget in main.yaml is a bug. `tool_summarizer.max_tokens` still reads
its main.yaml value first so nobody's existing configuration moves; new
installs reach the same number through agents.yaml like everything else.
GraphRAG's reachability probe is the one documented exemption — tuning it
could only make a health check lie.
Seeds are derived from the same tables the pipelines read, because two
lists of the same numbers is how a default and its seed drift apart —
the shape of #1316. Tests pin both halves: the shipped values, and that
every stage in code is present in the seeded file.
No behaviour change: every default is the constant it replaced.
6902 passed, 24 skipped.
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.
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.
Ship a content workspace you choose, one exec tool for every language,
Mastery Path modes that gate its tools, and Settings that grades
readiness instead of listing faults.
Release notes: assets/releases/ver1-6-5.md
Ship lighter isolated runtimes, richer Books and Mastery flows,
Reading/session polish, and explicit model API capabilities.
Release notes: assets/releases/ver1-6-4.md
Ship the breaking front- and back-end runtime and route refactor,
learner and guardian flows, grounded reading, knowledge and parser
updates, and recoverable long-running streams.
Release notes: assets/releases/ver1-6-3.md
When a required string key is present but blank, tell the model it sent an empty value instead of framing it as omitted — thinking models otherwise retry the identical call. Also clarify obsidian_create_note.content must be non-empty.
Model configuration was one layer replicated seven times: every service
stored its own profile with its own credentials, so a single OpenRouter
key had to be pasted into five separate pages. This release splits that
in two — a **connection** holds one vendor credential and links it down
to every service that vendor can serve, and a **task model** takes the
calls nobody asks for (naming a conversation, writing the composer's
starting points) off the model picked for actual reasoning. Both are
opt-in; existing per-service profiles resolve exactly as before.
Around that: Settings drops the card grid for a persistent searchable
navigator whose landing page answers "what state am I in" instead of
repeating the directory; Mastery Path files study conversations under
their topic and opens them in the tutor rather than dropping them on
/home; the sidebar folds features into More and reorders by drag; the
reading companion is rebuilt from /home's own chat components; and the
LightRAG engine talks to the SDK directly, so its extra no longer drags
MinerU in transitively.
Also back-merges PR #1041 (Anthropic SDK 1.x temperature via extra_body)
and PR #741 (owner-only auth secret/token files), which had been merged
straight into main and never flowed back to dev.
Release notes: assets/releases/ver1-6-1.md
Gates: pre-commit 15/15, ruff clean, pytest 5802 passed, web 450 node
tests, eslint 0 errors, docs build clean.
A mastery topic's sources were consumed exactly once — to ground outline
generation — and then never seen again. Tutoring carried none of them, while
the tutor's own system prompt claimed to "teach from the learner's own
materials". Asked "can you see the materials I gave you?", the tutor answered
"I can see them!" and cited a framework it had only ever read in a module name.
Express topic materials in the vocabulary the chat runtime already speaks: an
Attached-Sources-style manifest plus a {source_id: full_text} index. Filling
those two values on a mastery turn is enough — ExploreContextCapability
activates on a non-empty source_index and runs its read_source investigation
before the tutor's first LLM call. No new tool, no new loop, no change to any
other capability.
Books are split per chapter: a whole book cannot be one tool result, and a
chapter is the unit one knowledge point needs. Knowledge bases are listed but
carry no id — they are searched with rag, not read. Materials that cannot be
loaded are listed as unavailable rather than dropped, because being able to
name what it does not have is what stops the tutor inventing it.
Verified on a live turn against a real book: the tutor now calls
read_source(bk-...-ch_...) and answers with the six real chapters; pointed at
an unreadable book it says so and offers the knowledge base instead.
Course Study turns were ending on "I could not produce a useful response
from the model output", with the real recommendation sitting collapsed in
the trace above it — and, in one observed turn, written out three times.
The loop treats prose emitted alongside a tool call as a preamble: it is
streamed into the trace, and the answer is whatever a later tool-less
round says. That is right for tools that fetch something. It is wrong for
this playbook, which asks for the opposite shape — recommend the next
action, say why it is timely, then call `course_handoff`. The
recommendation and the call are one thought, and models write them in one
round. Dropped from the answer, the model had nothing new to add on the
next round, so it called `course_handoff` again until the budget ran out
and the turn finished empty.
The partner-group capability documents the same failure for
`invoke_other` and already carries the remedy: classify the tool round's
prose, then end the turn on it. Course Study now implements both hooks.
Two details worth keeping:
`_capability_answer_published` is deliberately not set. It means "the
learner has already seen this text, do not emit it again", which holds
for capabilities that buffer output behind a protocol. This mode buffers
nothing, so claiming it left the message body empty with the whole
recommendation hidden a click away — the original symptom, differently
caused.
A bare `course_handoff` with nothing said is left alone rather than
ending the turn: there is no answer to rescue, and the model still gets
its ordinary finish round to write one.
The flag was named `_partner_group_formal_answer_published` while living
in the generic loop, which now has a second caller; renamed to match what
it is.
A course held the right model — the syllabus that gives progress a
denominator, resources as references, conventions apart from the
assistant's own notes — but almost nothing crossed the edges between it
and the surfaces it was supposed to contain.
Getting in. Course Study was offered in the composer's mode menu while
the only way to bind a course was a link on the course page, so choosing
it there produced a conversation identical to an inert one, and the mode
advised pressing a button that did not exist. The composer now carries
the binding next to the mode: shown whenever there is one, and offered
as an unfinished field in Course Study when there is not. `_course_id`
rides every turn, so detaching detaches and the pill can never drift
from what the turn actually saw.
What a conversation inherits. `default_capability` and `default_persona`
were stored, validated and returned by the API while changing nothing:
`_apply_course_defaults` only fills fields a payload *omits*, and this
composer always sent all of them. They are applied client-side now,
along with the course's knowledge bases, where the learner can watch the
mode and material become the course's before they type. The dialog grows
the editor they never had.
Conventions. "Every conversation in this course starts knowing these" was
true only if the model happened to call `course_overview`. They ride in
the per-turn summary now, and — because the promise is not scoped to one
mode — in the system prompt of any course-bound turn.
Coming back. Mastery Path and Immersive Reading now read `?course=`,
scope themselves to it, and attach whatever is built there; the tiles and
hand-offs pass it; the picker offers to start one. A course could only
ever reference what already existed, so filling a new one meant leaving,
building, and remembering to return.
Hand-offs. A target with no ref stored an opening line for an index that
never consumes it, which then surfaced weeks later in an unrelated path.
An unresolvable ref was passed straight through: observed live, a
syllabus unit id ("u2") sent as a mastery path, producing a card pointing
at a page that does not exist. Refs are checked against the subsystem
that owns them — existence, not membership, since a path built outside
this course routes perfectly well.
Also: the sidebar groups conversations by course, so filing them is
finally readable; a course-scoped notebook console no longer shows
another course's notes beside a list saying there are none (the clear
raced an in-flight detail fetch that landed after it); a hand-off the
model also printed as prose is not rendered twice; a provider error is no
longer stored as a conversation's permanent title; `/space/courses` goes,
having been an unreferenced copy of `/courses`; and the Visualize mode
description gets its missing Chinese.
mastery_build rejected everything that was not exactly
[{name, knowledge_points: [{name, type}]}]. Smaller and local models
routinely answer with 'objectives' instead of 'modules', 'title' or
'description' instead of 'name', bare strings instead of knowledge-point
objects, or a flat objective list with no module layer at all. Each of
those was dropped by a silent 'continue', so the path saved empty, never
appeared in Learning Space, and the learner saw no error (#1019).
Normalize the shape before validating it, and make the one remaining
failure state the expected schema instead of just refusing.