4752 Commits

Author SHA1 Message Date
Qiu
3e66b30aa0 fix(chat): isolate PDF attachment extraction (#3026)
* fix(chat): isolate PDF attachment extraction

Run PDF-bearing chat attachment extraction outside the API process and reuse the single PDF image pass for both page markers and embedded attachments. Addresses the chat attachment reproduction in #2865.

* perf(pdf): skip decoding images after the count cap

Keep lookups for previously accepted image references ahead of the quota check so repeated pictures are still mapped to each page.

* perf(chat): reuse native PDF markdown for text-only parsing

Match the stored attachment bytes and preserve the configured parser path for other engines and incomplete native results.
2026-11-30 13:56:01 +08:00
zszz3
cc1da61b90 fix: keep a declared empty reasoning_content on loop tool rounds
The provider-side fill only adds "" once another round in the request
already carries reasoning. A thinking model that calls a tool with no
reasoning on the very first round of a turn (or on every round so far)
still got the field dropped, and DeepSeek rejected the next request.

The stream says whether the model is thinking: DeepSeek in thinking
mode sends reasoning_content (as "" when it has nothing), and never
sends the key with thinking disabled. Record that on LLMCallResult and
send the tool round back with "" when the field was declared. Providers
that never send the field get nothing added.

Refs #2976
2026-11-30 13:55:25 +08:00
zszz3
18a686b13b docs: rewrap memory audit prompts and note what was measured
The English audit_l2 / audit_l3 role paragraphs kept the short lines
left by moving the surface and slot names to the end; they are
rewrapped with the same words. The research forced-finish docstring now
says the tool_choice="none" behavior was measured on deepseek-flash
only.

Refs #2974
2026-11-30 13:45:50 +08:00
zszz3
9c4b74deda fix: drop the inline copy of the geogebra user template
The fallback used when geogebra_user.md is missing had no "## 图片"
section, so it already differed from the file. The file ships as
package data like geogebra.md, so the agent now reads it directly and
the test checks the image section reaches the user message.

Refs #2974
2026-11-30 13:44:53 +08:00
zszz3
4cc6cff77b fix: scope the shared visualizer rules to built-in types
The prompt catalog states the shared rules once under "General rules
for every type", but the same catalog also lists installed user
plugins, which never carried those rules. The heading now says "every
built-in type", so a user plugin is held only to its own rules.

Refs #2974
2026-11-30 13:36:32 +08:00
zszz3
0313e76227 docs: update workspace_system_note for its current callers
The docstring still said pipelines pass state_turn_path=True to embed
the turn folder. After the deep_question and deep_research changes no
caller does: every system prompt that uses the note is a cached prefix,
and the exact folder goes to the user message.

Refs #2974
2026-11-30 13:34:09 +08:00
zszz3
a5c8f53041 test: make the cache layout tests check what they claim
Two assertions could not fail: "report" in the research user message
matched other words, and the question number check passed for any digit
near the template heading. They now look for the rendered mode
(``report``) and for "#n of 3" / "第 n/3 道". The research forced-finish
docstring said tool_choice="none" while the test asserts "auto".

Refs #2974
2026-11-30 13:32:33 +08:00
zszz3
8b4bbf0c7e fix: leave a note when a forced finish round only calls a tool
The forced FINISH round keeps the loop's tools, so the model may still
call one. That call is not run, and the assistant turn added before the
repair note had empty content plus the round's reasoning or thinking
blocks. Anthropic rejects an empty text block, so the turn now carries a
short note ("Tool call not run: this round must finish.") when the round
returned tool calls and no text. Rounds that returned text are unchanged.

Refs #2974
2026-11-30 13:30:16 +08:00
zszz3
b2ab33d09c test: cover a tool call in deep_question's forced finish
The research block already tests the case where the model calls a tool
in the forced FINISH round; deep_question's _force_finish had no such
test. The new test checks that both requests carry the tools, the call
is not dispatched (no tool or tool_calls messages) and the repair note
is appended before the second attempt.

Refs #2974
2026-11-30 13:26:58 +08:00
zszz3
791ba307c0 docs: place the tool manifest comment and restore docstring accurately
The runtime-snapshot comment had drifted above TOOL_MANIFEST_SNAPSHOT
instead of RUNTIME_BLOCK_NAMES. _restore_tool_manifest's docstring said a
native request never carries a tools snapshot and that the next turn keeps
it current; replayed history can carry one, and it is kept only while the
previous turn on the same route recorded a rejection.

Refs #2973
2026-11-30 13:24:14 +08:00
Marcello Pichini
6b00f0109c fix: combine adjacent minute and second duration units (#2684) 2026-11-30 11:32:40 +08:00
Chen jizhou
79a66cb3c1 perf: stop idle activity orbs and narrow theme observers (#2704) 2026-11-30 11:12:41 +08:00
bluefateludi
4277138581 perf(auth): format only the requested account for profile lookups (#3033) 2026-11-30 11:12:32 +08:00
1zrj
24aa2632d9 fix learning activity (ReadingCompanion, MasteryStudy, NoteCompanion) chat auto-follow (#2935) 2026-11-30 11:12:23 +08:00
Benjamin Schwing
15489b72cf fix(question): read an uploaded exam paper back from the attachment store (#2949)
Mimic mode never parsed a paper uploaded from the web composer. The turn
executor stores every upload in the attachment store and then clears the
inline base64 of each document it has extracted, so the PDF attachment
reached DeepQuestionCapability with an empty base64. The upload branch was
skipped and the turn fell back to the plain-text "[Attached Documents]"
hint: no exam parsing, no question extraction and no templates.

When the attachment carries no inline bytes, the capability now resolves
the stored file by session and attachment id, the same lookup the chat PDF
parser uses, and parses it as before. Inline base64 is still used when
present.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
2026-11-30 11:12:14 +08:00
David Alvarez
bad3f4230c fix(multi-user): prune stale deleted LLM models in GrantEditor (#3084) 2026-11-29 23:31:12 -03:00
supermario_leo
f8cf0224b9 fix(multi_user): keep an unreadable account store instead of resetting it
A users.json that exists but cannot be read as a JSON object was treated as
an empty store, so the next write replaced every account with a single record
promoted to admin, and is_first_user() reopened /register for anyone.

Separate "no store yet" from "store is unusable": an absent, zero-byte,
whitespace-only, byte-order-mark-only, null, [] or JSON-scalar document holds no
accounts and still bootstraps; invalid JSON and a non-empty array are reported.
load_users() reports the problem once a minute per path, and the single write
funnel refuses to replace the operator's bytes, raising AccessError(503) for an
unreadable store and for a write the volume rejects, including a first boot on
an unwritable volume.

The caller-facing detail names the bare file and the remedy; the parse failure
and the absolute path stay in the operator log, because OS error text embeds the
path in a repr-escaped form that cannot be redacted reliably.
2026-11-30 06:49:38 +08:00
Mohammad Hijjawi
241192f135 fix: keep hand-written memory bullets on the next write
The memory parser only reads bullets that carry an entry-id anchor, and every
write path (write_memory, entry delete, consolidation) parses the file and
serializes it again. A bullet added in the workbench editor has no anchor, so
the next write dropped it.

Anchor new bullets when the editor saves a document, so they parse as normal
entries and survive later writes.
2026-11-29 20:49:34 +00:00
zszz3
8819d95c21 fix: keep the loop's tools in forced final rounds
When a research block or a deep_question explore/quiz loop runs out of
rounds, the forced FINISH request was sent with no tools. Removing the
tools changes the first bytes of the request, so none of the block's
history is served from the provider cache. In a real deep_research run a
block's forced finish paid 28.6k and 279.8k uncached tokens.

The forced rounds now send the loop's tool schemas unchanged; the prompt
already tells the model to stop calling tools. tool_choice="none" is not
used because DeepSeek renders it like no tools (replayed: 1,152 cached
tokens with "none" or no tools, 14,976 with the tools left as they were).
A tool call in a forced round is not dispatched; it fails the attempt and
gets the existing repair note.

Refs #2974
2026-11-30 03:47:50 +08:00
zszz3
9412a7c435 fix: send geogebra instructions as system prompt and the question as user 2026-11-30 03:47:50 +08:00
zszz3
5e74399525 fix: state shared visualizer rules once in the prompt catalog 2026-11-30 03:47:50 +08:00
zszz3
02ef1f70b0 fix: move run-specific values to the end of memory consolidator prompts 2026-11-30 03:47:50 +08:00
zszz3
0261ecac1f fix: move per-block research state out of the cached system prompt 2026-11-30 03:47:50 +08:00
zszz3
df02c70dff fix: keep deep_question system prompts stable across questions and turns 2026-11-30 03:47:50 +08:00
Alex Castillo González
218dbe31b9 fix(mastery): document observation-only fields in the teaching_updates schema (#2872)
TeachingUpdate.model_json_schema() gave knowledge_point_id, strategy and outcome no description, so models filling a preference also set strategy and the call is rejected by check_semantics. Add per-field descriptions (flat schema kept) and a test.
2026-11-30 01:42:44 +08:00
AleFlyX
633ca7656f Merge PR #2999: fix(embedding): keep transport retries independent of rate-limit retries
A read timeout after repeated HTTP 429s still gets a transport retry at the normal initial backoff. All 193 embedding tests passed.
2026-11-29 22:56:32 +08:00
OrdoAbChao7
8cb561362f fix(setup,llm): clear API key on vendor/region switch, unify compat retries, and honor Anthropic declared_reasoning 2026-11-29 20:49:02 +08:00
Benjamin Schwing
edafb90b41 chore(api): refresh the router index fingerprint 2026-11-29 12:38:13 +00:00
windyovo
bee9c1148b feat: reuse completed audio for read-aloud replays 2026-11-29 20:24:35 +08:00
windyovo
f9100e979d feat(voice): read elementary math aloud in Chinese 2026-11-29 20:23:45 +08:00
windyovo
e4f01a515e fix: refresh router index and lazy-load the speech decoder 2026-11-29 19:51:32 +08:00
Benjamin Schwing
e86fbf0ffe fix(assessment): move the shared verdict model into core
The quiz judge and question notebook routers belong to the server and
questions features, which do not depend on mastery. Importing the verdict
model from deeptutor.learning broke the isolated feature check. The model,
its result literal and the confidence threshold now live in
deeptutor.core.assessment; semantic_assessment re-uses them unchanged.
2026-11-29 11:26:01 +00:00
Benjamin Schwing
063ceba67a Merge remote-tracking branch 'origin/dev' into merge/quiz-judge-verdict
# Conflicts:
#	deeptutor/api/router_index.json
#	web/components/quiz/QuizViewer.tsx
2026-11-29 12:22:03 +01:00
OrdoAbChao7
555d1ed561 perf(web): keep /chat route within JS budget via reasoning-effort dedup and lazy selector 2026-11-29 19:20:45 +08:00
windyovo
c587678b71 feat: stream Volcengine audio for chat read-aloud 2026-11-29 19:14:38 +08:00
OrdoAbChao7
33edb5d648 fix(llm): scope reasoning fallback cache by endpoint and align DeepSeek Flash default_on 2026-11-29 16:48:49 +08:00
zszz3
91e04886be test: follow notes page state into runtime snapshots and the user seed 2026-11-29 16:32:47 +08:00
zszz3
3e0486cd21 fix: restore the text tool manifest when a provider rejects tool schemas 2026-11-29 16:32:47 +08:00
zszz3
bf77791ee9 test: pin a byte-stable system prompt while turn data changes 2026-11-29 16:32:47 +08:00
zszz3
2026ee4f18 fix: keep per-session data out of capability system blocks 2026-11-29 16:32:47 +08:00
zszz3
20bbe5e5fe fix: list only usable skills, as a runtime snapshot 2026-11-29 16:32:47 +08:00
zszz3
5e5c455b87 fix: move sidebar context and chat persona out of the system prompt 2026-11-29 16:32:47 +08:00
zszz3
d9a06eafd7 fix: drop the text tool manifest when native tool schemas are sent 2026-11-29 16:32:47 +08:00
AleFlyX
be2fe9104d Merge PR #2837: fix(rag): batch LlamaIndex rebuild checkpoints
Batch resumable embedding checkpoints and write the BM25 sidecar once after the final checkpoint, carrying over #2903. 45 targeted tests passed with the PR applied to dev. A 19-source rebuild retrieved the last source from the persisted BM25 index.
2026-11-29 16:32:15 +08:00
zszz3
578c359cc5 feat: let loop capabilities publish append-only runtime snapshots 2026-11-29 16:31:21 +08:00
Botong
dd29ff5a0a fix(i18n): sync frontend output language and remove zh-only UI fallbacks
Align frontend model-output language propagation and eliminate Simplified-Chinese-only UI shortcuts across chat, settings, books, reading, memory, and workspace surfaces:

- Preserve Traditional Chinese (zh-tw/zh-hk/zh-mo/zh-hant) and native aliases in resolveResponseLanguage(), and introduce shared effectiveResponseLanguage() and subscribeResponseLanguage() helpers.
- Sync response_language with language in SettingsStore when both were aligned, while preserving intentional divergence and clearing auto-synced pending response_language if an external desktop menu overrides language.
- Preserve per-conversation replyLanguageOverride when regenerating without a replay snapshot and subscribe ChatWorkspace's default reply-language label to live response_language changes.
- Route Book Creator, Book Chat fallback, Memory evolution/update, and Reading extension actions through effectiveResponseLanguage() instead of the UI language, and preserve zh-Hant in translationTarget().
- Route remaining zh ? ... : t(...) branches, hardcoded Memory labels, and binary zh/en date formatting through i18next and normalizeLanguage() so Traditional Chinese and all non-Simplified locales render through catalogs without modifying locale JSON files.

Related to #2933
Related to #684
2026-11-29 02:13:55 -06:00
zszz3
8ca3ebf869 fix: send an empty reasoning_content on reasoning-less tool rounds
A thinking model occasionally streams a tool call with no reasoning. The loop only writes reasoning_content when there is text, so DeepSeek rejected the next request of the turn with "The reasoning_content in the thinking mode must be passed back to the API". Once the request already carries reasoning elsewhere, the reasoning-less tool round now gets an explicit empty field.
2026-11-29 16:06:49 +08:00
Botong
24c55ee1f4 fix(i18n): fill European catalog gaps, plurals and stale French keys 2026-11-29 01:40:37 -06:00
lytanjie
ab51601b89 fix(web): keep statistics notation as inline math (#2878)
* fix(web): keep statistics notation as inline math

plausibleMathBody judged inline math by Latin words, so $Var(N)$, $Cov(X,Y)
and $Corr(X,Y)$ fell through escapeStrayDollars and displayed as source.
Add the common statistics functions to MATH_WORDS.

Also recover control characters left by JSON tool-argument decoding
(U+0008/U+000C/U+000D followed by a letter) back into \b, \f and \r, so
formulas already stored in notes render again.

Tests: latex-normalize.test.ts.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* fix(web): only restore a decoded escape that spells a KaTeX command

A form feed or carriage return in front of a word is not always a mangled
\frac or \right: text extracted from a PDF keeps a form feed between pages.
Rewriting every one of them showed a stray "\f" in front of the next word.
Restore the backslash only when the letters after it name a KaTeX command.

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: zszz3 <91608029+zszz3@users.noreply.github.com>
2026-11-29 15:29:03 +08:00
Zhuoran Wang
3ce3d47858 Fix quiz-attempt 500 when the Book entity has no chat_session_id (#2692)
* Fix quiz-attempt 500 when the Book entity has no chat_session_id

book.py's attempt sync read book.chat_session_id, an attribute that only
exists on CreateBookRequest/BookInputs (a legacy creation-time shorthand)
and is not persisted on the Book model — so every quiz attempt without a
page-bound chat session raised AttributeError after the progress was
saved, returning 500 and dropping the Focus-Check assessment sync.

Read only the persisted per-page mapping, and cover it with a regression
test whose fake mirrors the real entity (no chat_session_id attribute).

* style: apply ruff format

* chore(api): refresh router index for the book router

---------

Co-authored-by: zszz3 <91608029+zszz3@users.noreply.github.com>
2026-11-29 15:28:55 +08:00