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