298 Commits

Author SHA1 Message Date
Qiu
fda9efa57d refactor(turns): share durable turn status classifications (#3122)
* Share durable turn status groups across application and stores

* Verify durable status groups against SQLite active lookup
2026-12-01 21:36:55 +08:00
Carl
242b24beeb fix: keep chats usable after oversized tool calls (#3144)
Closes #2909.

Omit the fewest eligible historical tool-argument payloads so oversized completed exchanges remain replayable, without touching signed/native provider rounds or durable history.
2026-12-01 17:03:29 +08:00
Yuchuan He
73bfa3f9e0 fix(turns): prevent duplicate replies when Stop races persistence (#3074) 2026-12-01 13:54:56 +08:00
wojiecihuo
fed428e46a Merge pull request #3079 from zszz3/fix/chat-runtime-snapshots
fix: keep turn data out of the chat system prompt and drop the duplicate tool manifest
2026-11-30 23:21:32 +08:00
Udaya Vijay Anand
593bffac0e perf(session): copy stored model turns without JSON round-trip (#2803) 2026-11-30 15:10:57 +08:00
游标卡尺
9d014a27e2 fix(session): stop existence checks from re-serializing stored model turns (#2807)
Long mastery sessions froze the event loop: every existence-only probe
(history_groups, context-builder guards) ran normalize_model_turn, which
deep-copies the whole request record via a JSON round-trip. A 121-message
session re-serialized megabytes per probe, holding the GIL long enough for
health checks to time out and the worker to be declared lost.

Extract the structural acceptance checks into _is_complete_model_turn and
add has_model_turn for existence-only sites. normalize_model_turn delegates
to the same predicate, then cleans and copies as before, so replay keeps its
full isolation. Stored records are normalize's own JSON-safe outputs, so the
predicate accepts exactly what normalize accepts on stored rows; a parity
corpus pins the shared rejections.

Fixes #2788

Co-authored-by: ZQR1101 <278034003+ZQR1101@users.noreply.github.com>
2026-11-30 15:10:40 +08:00
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
3e0486cd21 fix: restore the text tool manifest when a provider rejects tool schemas 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
wojiecihuo
ce831dd4c3 fix: keep sent runtime snapshots in mastery replay, and keep them small (#2992)
* fix: keep sent runtime snapshots in mastery replay

Mastery replay dropped every runtime snapshot from history and the loop
re-appended them after it, so each follow-up request diverged from the
previous one at message 1 and only tools + system hit the prompt cache.

- project_mastery_replay(keep_snapshots=True) for the tutor request and
  its token accounting; memory material still drops snapshots
- replay_group no longer blanks a tagged mastery_status_snapshot while
  removing the legacy fused suffix
- status snapshot anchors are numbered from the start (occurrence), so a
  later snapshot never changes how an earlier turn is projected

Refs #2922

* fix: keep runtime snapshots out of the mastery history budget

Replayed snapshots stay in the request so follow-up turns extend the cached prefix, but counting them made a large mastery_status snapshot push the history over its 20k budget after two turns; the next turn then paid a memory rewrite and a full prefix miss. The budget now measures the learning history only, as before. Refs #2922

* fix: bound the runtime snapshots kept in mastery history

Keeping sent snapshots out of the history budget entirely let many short
exchanges accumulate them without limit (80 quiz-style turns: 5.4k counted,
62k sent). Dialogue still keeps to the plan; dialogue plus snapshots keep to
twice the plan, and only as far as the model's window allows. Refs #2922

* fix: keep only this turn's state in the mastery status snapshot

Every mastery turn sends a fresh mastery_status snapshot and, since the
replay change, keeps earlier ones in history, so whatever a snapshot
carries is paid for once per turn and then kept. A full status read
repeats fixed guidance (open question, question group, working brief,
intake, teaching guidance and focus) and every default value of every
knowledge point.

The snapshot now drops empty and default values and the fixed guidance.
That guidance lives in named constants and is stated once in a new
mastery_status_guide system block, which also explains the omitted
defaults. Snapshots start with a one-line header; history sharing reads
both the header and the longer notice older sessions stored. An explicit
mastery_status call still returns the full payload.

Measured over 54 recorded snapshots: working briefs 1,454 -> 645 tokens
(median), full outline snapshots 6,352 -> 2,954. The guide adds 861
tokens (en) to the cached system prompt.

Refs #2922

* fix: size the exact tail the way the plan does, and share full reads with compact snapshots

Two gaps left by keeping snapshots in mastery replay (review on #2992):

- Recent-history selection counted kept snapshots in full while the plan
  discounted them, so a session of short exchanges with large snapshots
  archived most of them as soon as selection ran. ContextBuilder now sizes
  the candidate tail through _recent_history_tokens(), and the mastery
  builder answers with the same _plan_tokens() measure.
- Snapshots carry the compact form of map, learner_profile, learning_stages
  and visual_requirements, so a later full mastery_status result never matched
  them exactly. Sharing now also compares a full field's compact form and
  marks such references with "defaults_omitted": true, which the state
  reference notice explains.

Also: rename _next to _compact_next_step, and say in the status guide that
the omitted-default rules cover only what the snapshot includes.

Refs #2922
2026-11-28 12:57:21 +08:00
LIziak112
a5e3e0a808 fix: make the repository pre-commit checks portable on Windows (#2966)
Independent maintainer review approved for 257c5e62. Windows Python 3.12 pre-commit 15/15, targeted Windows and WSL Linux regressions passed; latest HEAD CI has no failures.
2026-11-26 18:36:45 +08:00
Bingxi Zhao (Frank)
719e2a8e30 fix(chat): inherit ready workspace knowledge bases for untouched sessions 2026-11-15 01:00:49 +08:00
Bingxi Zhao (Frank)
b266d1a14d fix(chat): preserve sent history snapshots for prompt cache reuse 2026-11-15 01:00:14 +08:00
Bingxi Zhao (Frank)
30a7e43001 fix(memory): capture chat questions and rebuild missing L2 documents
Local dev repairs for #2294.

Memory, regeneration and decoding suite: 398 passed; regeneration does not duplicate trace events.
2026-11-15 00:50:30 +08:00
Bingxi Zhao (Frank)
e885120cf6 fix(runtime): preserve live turns owned by another local process
Local dev repairs for #2168, #2631.

Real child-process recovery: 16 tests passed, including queued, running, waiting_input, process exit and PID reuse. Existing coordination/application tests: 65 passed, 10 optional Redis skips.
2026-11-15 00:50:30 +08:00
Bingxi Zhao (Frank)
e0872716f0 fix(runtime): announce input waits and reject oversized history plans
Local dev repairs for #2387, #2433, #2496. Regression checks cover reported symptoms and compatibility boundaries.
2026-11-15 00:44:09 +08:00
Bingxi Zhao (Frank)
af403550ce Merge PR #2639: fix: explain missing LLM access in chat
Retain admission error text and localized model-access guidance; allow explicit retry to revalidate access instead of permanently blocking stored messages. No automatic retry on reload. Backend tests and both manual retry paths passed.
2026-11-14 23:19:09 +08:00
Bingxi Zhao (Frank)
dc537c9367 Merge PR #2527: fix: keep first-chat tokenizer acquisition local and nonwaiting 2026-11-14 23:00:45 +08:00
Bingxi Zhao (Frank)
83f18f1be2 Merge PR #2577: feat(sidebar): group a practice session's questions into one Learning Records row 2026-11-14 23:00:04 +08:00
Bingxi Zhao (Frank)
c60e0e0331 Merge PR #2576: feat(reading): record question-linked help without replacing the quiz
Keep server-only quiz answer keys before persisting help results; retain relationship and extension-policy revalidation.
2026-11-14 22:59:16 +08:00
Bingxi Zhao (Frank)
211e19a85e Merge PR #2598: fix(session): give attached reading sections to non-chat capabilities 2026-11-14 22:58:00 +08:00
Bingxi Zhao (Frank)
3658dd6854 Merge PR #2633: fix(chat): label reinjected prior-turn images as historical 2026-11-14 22:52:56 +08:00
Bingxi Zhao (Frank)
00f26d3fb0 Merge PR #2592: fix(llm): preserve encrypted thinking in Anthropic tool continuations 2026-11-14 22:51:16 +08:00
riccardo-algorime
2514313937 fix(session): cap attached reading sections for non-chat capabilities
All attached units together stay within one unit's cap (60k chars). The unit
that crosses it is cut with a named marker; later units are listed by name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 11:47:55 +00:00
Junlin Li
560a80a17f fix: explain missing LLM access in chat 2026-11-12 16:58:52 +08:00
evan188199-tech
7d2989e250 fix(chat): label reinjected prior-turn images as historical
Images re-injected via chat_prior_image_reinject_max landed in the
current user message with no origin marker, so the model treated them
as fresh uploads of that message even when it was text-only. Mark the
collected prior images historical with their source message id and
insert a brief origin note before such images during multimodal
assembly; current-turn uploads keep their existing behavior.

Fixes #2632

Signed-off-by: evan188199-tech <238371241+evan188199-tech@users.noreply.github.com>
2026-11-12 06:14:40 +08:00
riccardo-algorime
1279257900 fix(session): give attached reading sections to non-chat capabilities
Chat turns reach attached reading units through the source inventory and
read_source. Deep Solve, Visualize, Math Animator and the other non-chat
capabilities get attachments inlined into the user message instead, but
reading references were left out there, so a turn with reading sections
attached ran without them. They now go in as [Reading Sections], next to
[Attached Documents] and [Book Context].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 13:50:51 +00:00
stefanielizeth73-art
1278483a64 fix(llm): preserve redacted thinking during tool continuation 2026-11-10 19:57:16 +08:00
evan188199-tech
a074bcfcb9 feat(sidebar): collapse one practice session's questions into a single Learning Records row
Practice notebook entries recorded in one session now share a single
sidebar row, titled by that session with its question count, expandable
to each question's own practice link. Entries without a session (and
sessions that produced one question) keep individual rows, and the
Question Bank, answers and review links are unchanged.

The learning index navigation read gains the existing session id and
title (no new persisted field); grouping happens in the projection.
Sidebar strings added to every locale.
2026-11-10 00:33:52 +08:00
Yin
caee2c5ff6 feat(reading): persist question-linked help receipts and events 2026-11-10 00:12:58 +08:00
evan188199-tech
5177b4d48f fix: keep first-chat tokenizer acquisition local and nonwaiting 2026-11-09 00:42:38 +08:00
Tazeem Mahashin
ee1dd2c8d5 fix(runtime): replay submissions during concurrent admission 2026-11-06 19:32:37 -05:00
Bingxi Zhao (Frank)
60fb3bdfdd release: v1.7.2
Document selected-text speech, model discovery, NVIDIA NIM embeddings,
mastery reliability, Windows improvements, and complete desktop downloads.

Sync all eleven README translations and archive the v1.7.0 release notes.
Add platform-specific typing annotations for Windows APIs without changing
runtime behavior. See assets/releases/ver1-7-2.md for changes and upgrades.

Validation: pre-commit and Ruff passed; 12,782 Python tests passed
(51 skipped), 1,349 Node 22 tests passed, and the docs build passed.
2026-11-06 16:41:21 +08:00
Bingxi Zhao (Frank)
ebcebd4723 Unify migration locks and plugin environments, and cover compatibility boundaries 2026-11-06 02:04:52 +08:00
Bingxi Zhao (Frank)
4c971e51f3 Merge #2303 from Antonio-Faure 2026-11-06 01:56:40 +08:00
Bingxi Zhao (Frank)
ed10ea2137 Merge #2281 from Plastic-time 2026-11-06 01:56:39 +08:00
Bingxi Zhao (Frank)
b2fb16d682 Merge #2275 from Plastic-time 2026-11-06 01:56:39 +08:00
Bingxi Zhao (Frank)
8b14aa5ffe Merge #2402 from KKandLL-Forever 2026-11-06 01:56:25 +08:00
wangkai
26e3a4b52c fix: reject mismatched mastery card replay receipts 2026-11-03 10:53:45 +08:00
Adithya
4dd10949b7 fix: add chat context summary prompt resources 2026-11-02 22:06:17 +05:30
Antonio-Faure
75d65b7dea fix(tutor): retry a failed source attribution after a cooldown 2026-11-01 10:35:58 +01:00
RRFZ
fd04d19469 fix(session): keep waiting for the Windows schema lock past LK_LOCK's limit
msvcrt's LK_LOCK gives up with EDEADLK after about ten seconds, and a
one-time upgrade of a large session database can hold the lock longer than
that. Retry on EDEADLK so the other workers wait, as flock does on POSIX;
any other lock error still propagates.
2026-10-31 22:47:42 -04:00
RRFZ
4de11b45f9 fix(session): keep waiting for the Windows migration lock past LK_LOCK's limit
msvcrt's LK_LOCK gives up with EDEADLK after about ten seconds, and a worker
importing a large legacy store holds the lock longer than that. Retry on
EDEADLK so the other workers wait, as flock does on POSIX; any other lock
error still propagates.
2026-10-31 22:46:06 -04:00
RRFZ
bf20e3c4da fix(session): serialize the legacy chat migration on Windows too
LegacyChatSessionMigrator.migrate runs under _migration_lock because
every worker runs it at startup, but the lock used fcntl only and was a
no-op on Windows. Workers there copied, imported and archived the same
v1 sessions file at once: with 4 processes x 5 rounds, 17 of 20 runs
failed (LegacyMigrationError from colliding imports, WinError 32 on the
backup copy).

Take an msvcrt byte-range lock when fcntl is unavailable, in the same
shape as the other cross-process locks.
2026-10-31 22:13:50 -04:00
RRFZ
1a54befba8 fix(session): serialize session-store schema setup on Windows too
SQLiteSessionStore runs its WAL switch and schema creation under
_migration_lock, which serializes worker processes with fcntl.flock but
was a no-op on Windows. Processes opening the store together there
raced: on a fresh database 14 of 30 concurrent opens failed with
"database is locked" (PRAGMA journal_mode = WAL) or "trigger
practice_capture_update already exists".

Take an msvcrt byte-range lock when fcntl is unavailable, in the same
shape as the grants, cron and Codex-auth locks.
2026-10-31 21:36:09 -04:00
Bingxi Zhao (Frank)
def8bdc8c6 Merge commit '1876207b5c248eb4ee4375e34779ed332a11d284' into codex/validate-reviewed-integration 2026-10-31 18:52:30 +08:00
Bingxi Zhao
e35a528cca Merge pull request #2145 from meconopscsh/fix/cjk-emphasis-ja
fix: repair CJK emphasis boundaries for Japanese and Korean replies too
2026-10-31 18:39:18 +08:00
Bingxi Zhao (Frank)
d002053ab9 Merge dev and refresh the API routing index 2026-10-31 17:26:35 +08:00
Bingxi Zhao (Frank)
a0b5721ab6 fix(tutor): detach recycled threads before deleting source messages 2026-10-31 17:26:25 +08:00
Bingxi Zhao (Frank)
f6313b70a1 fix(tutor): detach PocketBase thread anchors when regenerating 2026-10-31 16:52:54 +08:00