Commit Graph

816 Commits

Author SHA1 Message Date
Bingxi Zhao (Frank)
5f7e165161 fix(llm): carry a round's reasoning through the shared agentic loop
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.
2026-09-08 00:52:57 +08:00
Bingxi Zhao (Frank)
71e042fead fix(chat): let a user ask for another language, and stop the two copies drifting
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.
2026-09-08 00:46:09 +08:00
Bingxi Zhao (Frank)
352f7d1793 fix(partners): refuse turn-owning KB kinds, and finish connected provisioning
#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.
2026-09-08 00:42:30 +08:00
Bingxi Zhao (Frank)
8ee2258be4 fix(mastery): declare mastery_mode as a rebinding tool
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.
2026-09-08 00:34:13 +08:00
Bingxi Zhao (Frank)
e7d04fccfc fix(knowledge): validate KB names on the manager, and let a bad one be deleted
A knowledge-base name is three things at once: a kb_config.json key, a
directory under data/knowledge_bases, and a path segment in every per-KB API
route. `validate_knowledge_base_name` exists to keep those three uses
compatible — its docstring says so — but it was called from one of the eight
HTTP entry points that can write a name into the config. The seven connect-*
endpoints (Obsidian, MarginNote, folder, LightRAG server, WeKnora, IMA, and
the subagent connection) did `(name or "").strip()` and wrote the result.

A name holding a "/" registers fine that way and is then unreachable.
uvicorn percent-decodes the path before routing, so %2F is a real separator
by the time Starlette matches `{kb_name}` — compiled to `[^/]+`, which cannot
span it. All 29 per-KB routes 404, delete included, while the list endpoint
takes no path parameter and keeps rendering the KB. Connected KBs are also
exempt from the orphan prune, so nothing collects it either: visible, unusable,
and removable only by hand-editing kb_config.json.

Two changes, both needed. Validation moves onto the eight `register_*`
methods, which is the seam every route already goes through — no route file
changes, since they all map ValueError to 400 — and the now-unreachable
"name is required" guards go with it. And a path-free
`POST /knowledge-bases/delete` gives the entries that predate the guard a way
out; a body is never split into segments. Widening the path route to
`{kb_name:path}` would not work: it is declared ahead of the DELETE routes
for linked folders, GitHub sources and web sources, and a greedy converter
would silently swallow all three.

Two smaller fixes ride along. The delete handler's catch-all swallowed its
own HTTPException and answered 500 with "404: ... not found" in the detail;
it now re-raises. And CreateKbModal states the rule under the field instead
of letting an untranslated English 400 be the first the user hears of it.

test_marginnote4_kb's store-collision case used "My Lib" / "My/Lib"; the
slash is now refused before that guard is reached, so it uses "My.Lib" —
still a name the rule allows, still sanitized to the same My_Lib.db.
2026-09-08 00:31:59 +08:00
Bingxi Zhao
be15a50ed7 Merge pull request #1271 from georgelichen/fix/responses-input-status-compatibility
fix(llm): retry Responses requests without unsupported status
2026-09-08 00:03:09 +08:00
Bingxi Zhao (Frank)
e27f4c2cd7 Merge remote-tracking branch 'origin/dev' into fix/responses-input-status-compatibility 2026-09-08 00:01:52 +08:00
Bingxi Zhao (Frank)
da285f236b refactor(knowledge): give connected-KB adoption a public entry point
Provisioning reached across modules for `KnowledgeBaseManager.config` and
`_save_config()`, which put a partner-workspace concern inside the manager's
private state. `register_connected_entry` states the operation instead: adopt
an entry that already exists, refuse anything that is not a pointer KB, and
report whether it was new so provisioning stays idempotent the way the
copytree branch is.
2026-09-08 00:00:27 +08:00
Bingxi Zhao (Frank)
8a2391095a Merge remote-tracking branch 'origin/dev' into fix/1259-partner-connected-kb-provisioning 2026-09-07 23:59:01 +08:00
Bingxi Zhao (Frank)
bc990b94e7 Merge branch 'dev' into codex/fix/chat-pdf-tool-hallucination
Drop this branch's copy of the CI repair, which landed on dev via
#1282/#1274, and the route-budget increases that came with it — `/` now
measures 202KB against the original 300KB budget, so the gate does not
need loosening. What remains is the fix: the answer loop no longer mounts
`read_source` (it is owned by the explore_context pre-pass), so the prompt
and the inventory docstrings stop implying it can reopen the materials.
2026-09-07 23:57:11 +08:00
Bingxi Zhao
f31acc1235 Merge pull request #1231 from evan188199-tech/codex/fix/learner-courses-1228
fix(learner): restore course access (#1228)
2026-09-07 23:47:59 +08:00
Bingxi Zhao
632540c944 Merge pull request #1260 from be-student/codex/1227-k3-256k-temperature
fix: support Moonshot k3-256k temperature override
2026-09-07 23:47:21 +08:00
Bingxi Zhao
b7aa30ffa7 Merge pull request #1264 from NoxsMedia/codex/nox-29-codex-catalog
fix(codex): expose eligible GPT-6 Astra in refreshed catalogs
2026-09-07 23:47:09 +08:00
Bingxi Zhao
c86cc59b09 Merge pull request #1275 from NoxsMedia/codex/nox-31-lightrag-1.5.7
chore(lightrag): upgrade native SDK to 1.5.7
2026-09-07 23:46:53 +08:00
Bingxi Zhao
a5847eebb8 Merge pull request #1258 from wangyuxy9805-web/fix/1245-question-notebook-image-upsert
fix: persist notebook answer images
2026-09-07 23:43:39 +08:00
NoxsMedia
86aa5d0edf fix: restore formatting and deterministic CI checks 2026-09-07 10:20:03 +00:00
XZH
b052060ae1 fix(ci): restore upstream test gates 2026-09-06 23:41:41 -07:00
NoxsMedia
de483d6554 chore(lightrag): upgrade native SDK to 1.5.7 2026-09-06 15:02:43 +00:00
Chen Li
35d30638cc fix(llm): retry Responses requests without unsupported status
Retry only exact structured 400/422 input[n].status rejections with a copied request body that omits message status fields.
2026-09-06 22:07:08 +08:00
XZH
6b96364d83 fix(chat): prevent PDF attachment tool hallucinations 2026-09-06 04:22:20 -07:00
NoxsMedia
6cfbbe93dc fix(codex): update model catalog compatibility version 2026-09-06 09:00:50 +00:00
Amir Fathi
31c8b104c6 fix(partners): register connected KBs instead of copytree-ing a folder that never exists
_copy_knowledge_base assumed every knowledge base has a data/knowledge_bases/<name>/
folder to copytree. Connected/pointer KBs (Obsidian, linked, ...) are registered in
kb_config.json only and never have such a folder by design, so assigning one to a
Partner always raised FileNotFoundError.

Branch on is_connected_kb() and register the same pointer entry in the partner
scope's own kb_config.json instead of copying.
2026-09-06 06:57:41 +00:00
Bingxi Zhao (Frank)
04040a2c06 release: v1.6.5
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
2026-09-06 13:46:29 +08:00
eunwoo song
73b6db8ec5 fix: support Moonshot k3-256k temperature override 2026-09-06 13:59:44 +09:00
wangyuxy9805-web
44ae34f653 fix: persist notebook answer images 2026-09-05 22:27:49 +08:00
XZH
bf4b55e926 fix(learner): restore course access (#1228) 2026-09-04 06:32:36 -07:00
Bingxi Zhao
269f65dede feat(subagents): add hardened remote Hermes backend (#1213) 2026-09-03 16:24:34 +08:00
Bingxi Zhao
c45f0ec58b refactor(video-learning): separate Invidious account adapters (#1211) 2026-09-03 16:04:57 +08:00
NoxsMedia
9cd1912c14 feat: add LightRAG indexing model controls and provenance (#1174)
* feat(knowledge): add LightRAG indexing model controls

* fix(knowledge): close NOX-21 review findings

* fix(knowledge): resolve NOX-21 review blockers

* fix(knowledge): identify unpublished LightRAG builds

* style: format LightRAG indexing changes

* fix(knowledge): align indexing controls with LightRAG model

* fix(knowledge): close indexing UI review blockers

* style: format knowledge router
2026-09-03 15:56:55 +08:00
NoxsMedia
ecc150d960 feat: pin LightRAG indexing models per knowledge base (#1171)
* feat(lightrag): pin indexing model per knowledge base

* fix(lightrag): close indexing isolation gaps

* fix(lightrag): integrate released dedicated model contract

* fix(lightrag): fingerprint vision capability

* test(rag): update LightRAG policy fixtures and harden redaction

---------

Co-authored-by: Bingxi Zhao (Frank) <13051345080@163.com>
2026-09-03 15:55:27 +08:00
evan188199-tech
f9721b61c4 perf(session): lazily load turn event traces (#1191)
* perf(session): lazily load turn event traces

* fix(session): bound trace previews at the storage layer

---------

Co-authored-by: XZH <cto@xzh.ai>
Co-authored-by: Bingxi Zhao (Frank) <13051345080@163.com>
2026-09-03 15:46:04 +08:00
evan188199-tech
6cc45698f0 feat(video-learning): connect Invidious accounts (#1192) (#1193)
* feat(video-learning): connect Invidious accounts

* fix(video-learning): harden Invidious authorization state

---------

Co-authored-by: XZH <cto@xzh.ai>
Co-authored-by: Bingxi Zhao (Frank) <13051345080@163.com>
2026-09-03 15:38:02 +08:00
evan188199-tech
db24303eb0 feat(learning): add visual learning board (#1194)
Co-authored-by: XZH <cto@xzh.ai>
2026-09-03 15:34:00 +08:00
evan188199-tech
793c8e24b8 feat(video-learning): export timestamped notes as markdown (#1203) (#1204)
Co-authored-by: XZH <cto@xzh.ai>
2026-09-03 15:30:31 +08:00
Boooobby
4069f900cc fix: preserve raw content during Chinese Markdown streaming (#1178)
* fix: normalize Chinese Markdown emphasis boundaries

* fix: preserve raw content during markdown streaming

* fix: sort turn executor imports
2026-09-03 15:30:26 +08:00
ZQR1101
5e47f0d3de feat(search): filter unsafe web-search titles and snippets (#1205)
Extend source_filter beyond URL hygiene with title/snippet heuristics, optional OpenAI Moderation, and an opt-in educational trusted-domains preset (#375 stage 2).

Co-authored-by: ZQR1101 <278034003+ZQR1101@users.noreply.github.com>
2026-09-03 15:30:21 +08:00
Dongyu
8ffa08d89e fix: detect source checkout for app updates (#1186)
Co-authored-by: weidongyu <dongyu-will@users.noreply.github.com>
2026-09-03 15:30:00 +08:00
Jinguang Gu
62b05fe6bb fix(llm): fall back on DeepSeek reasoning-replay 400s from Responses turns (#1195)
DeepSeek V4 thinking models (v4-flash, v4-pro) served through the
Responses API reject continuation requests whose input is missing the
prior assistant turn's reasoning item:

    The reasoning_text in the thinking mode must be passed back to the API.

Histories persisted before reasoning items were stored (or reused after
a provider/model switch) cannot satisfy the replay, and because the
error text matched none of the existing markers in
_should_fallback_from_responses_error, callers received a hard failure
instead of the existing Chat Completions degradation.

Add reasoning_text / reasoning_content / passed back / thinking mode as
recognized fallback markers. The Chat Completions path already sends
`thinking: disabled` for deepseek-v4-flash (#1058), so the fallback is
safe and preserves the turn; the circuit breaker then stops retrying the
Responses path for the probe interval.

Context: #1048, #1175.
2026-09-03 14:56:17 +08:00
Bingxi Zhao (Frank)
93df3d48b7 release: v1.6.4
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
2026-09-03 01:38:54 +08:00
Bingxi Zhao (Frank)
6e6e56aedb release: v1.6.3
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
2026-09-02 04:09:11 +08:00
Bingxi Zhao (Frank)
fc39543bc0 feat: integrate frontend backend and canonical routes 2026-09-01 22:24:29 +08:00
Bingxi Zhao (Frank)
02ba56793e chore: checkpoint backend stabilization workspace 2026-09-01 21:28:15 +08:00
Bingxi Zhao (Frank)
a36e902c38 feat(web): generate typed backend contracts 2026-09-01 17:06:01 +08:00
Bingxi Zhao (Frank)
3403f97b2a feat(contracts): export frontend REST and turn schemas 2026-09-01 16:48:55 +08:00
Bingxi Zhao (Frank)
7134ea6a38 fix(runtime): make Windows launcher browser-safe (#1147) 2026-09-01 02:52:02 +08:00
Bingxi Zhao (Frank)
90351189a1 feat(learner): complete guardian management flows 2026-09-01 01:52:13 +08:00
XZH
0cb0a269a7 chore(ci): format dev baseline for ruff 2026-08-31 08:55:52 -07:00
Bingxi Zhao (Frank)
6fccf929c0 Merge pull request #1142 from evan188199-tech/codex/feat/video-learning-transcript-notes 2026-08-31 22:29:17 +08:00
Bingxi Zhao (Frank)
5216f454b2 Merge pull request #1151 from evan188199-tech/codex/fix/sandbox-exec-limits 2026-08-31 22:21:00 +08:00
Bingxi Zhao (Frank)
cb9ba81d85 Merge pull request #1146 from ZQR1101/fix/video-learning-windows-fcntl 2026-08-31 22:12:31 +08:00