78 Commits

Author SHA1 Message Date
Bingxi Zhao (Frank)
8ab4ecfee9 feat(books): review and undo scoped chapter and section edits
Fixes #2571
2026-11-15 01:42:47 +08:00
Bingxi Zhao (Frank)
18e491d346 fix(rag): surface IMA content restrictions and seed retrieval failures 2026-11-15 01:04:25 +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)
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)
6c1e3b6e60 Merge PR #2549: fix(llm): map Anthropic context-window, refusal and stop_sequence stop reasons
Move the context-full finish reason into the shared LLM protocol and add English and Chinese notices; test both localized warnings and provider mappings (186 passed).
2026-11-14 23:09:35 +08:00
Bingxi Zhao (Frank)
68106fb79a Merge PR #2670: fix(loop): keep the workspace system note byte-stable across turns (#2621)
Sort the regression-test imports and apply targeted formatting; integrated workspace-note suite passed.
2026-11-14 23:04:53 +08:00
Bingxi Zhao (Frank)
47e4c33c90 Merge PR #2493: fix(runtime): separate indexless streamed tool calls 2026-11-14 23:00:46 +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)
16cc590b63 Merge PR #2564: feat(chat): per-conversation reasoning-effort selector in the composer (#641) 2026-11-14 23:00:04 +08:00
wmym
d4a9f88292 fix(loop): keep the workspace system note byte-stable across turns (#2621)
The chat loop replays the workspace note as the "workspace" runtime
snapshot, which lives inside the cached prompt prefix. The note embedded
workspace.logical_output_dir — outputs/chat/<session>/<turn>/ — so its
bytes changed on every turn: the snapshot-replace logic cut the old copy
out of the middle of the rebuilt history and appended a fresh one,
invalidating the provider prompt cache on every multi-turn request
(cached-token hit rate <1%; single-turn tool loops were unaffected).

- workspace_system_note(state_turn_path=False) keeps the replayed chat
  snapshot byte-identical for the whole session and points at the current
  user message for the exact path instead.
- new workspace_turn_note() delivers the per-turn output folder in the
  trailing user message — fresh bytes each turn, so cache-safe by
  construction.
- phase-built prompts (question/research pipelines) keep embedding the
  exact path via the default state_turn_path=True; their behavior is
  unchanged.
- model-history reconstruction keeps an exact prefix once snapshots are
  stable; new multi-turn replay tests assert byte-level prefix extension
  across three consecutive turns, plus the second factor named in the
  issue turns out to be a consequence of the turn-scoped snapshot and
  needs no separate change.

Verified: tests/agents/chat 273 passed; tests/capabilities 739 passed;
tests/services/workspace+session 709 passed (8 failures pre-exist on the
clean tree and are unrelated); remaining tests/agents failures pre-exist.
2026-11-14 00:48:42 +08:00
evan188199-tech
9782043ab3 fix(tools): keep web_search/web_fetch mounted in exclusive knowledge turns
Exclusive knowledge capabilities (obsidian, marginnote4, subagent) dropped
the whole chat built-in surface, including web_search (still shown on in
settings) and the always-on web_fetch. Add a coexisting_tools declaration
to KnowledgeCapability (default empty; the product KBs declare the web
pair), honoured in compose_enabled_tools' exclusive branch under each
tool's usual gate (user toggle / always-on / conditional flag) and the
partner builtin_whitelist, mirroring the #650 KB coexistence. The
capability's system prompt now also names what actually mounted via
coexisting_tools_block, so the model no longer disclaims mounted tools.

Fixes #2612

Signed-off-by: evan188199-tech <238371241+evan188199-tech@users.noreply.github.com>
2026-11-11 11:18:04 +08:00
Alex Castillo
f4566a3769 fix(llm): keep a full input context out of the output-truncation recovery
model_context_window_exceeded mapped to "length", which the agent loop
treats as an output cap and answers with continue_truncated, resending the
same full history. Report it as context_length_exceeded instead, and have
the loop end the round with a notice.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-10 11:52:13 -04:00
evan188199-tech
3b1730d758 feat(chat): per-conversation reasoning-effort selector in the composer (#641)
Carry the #958 service-layer reasoning_effort override through the whole
turn contract: the core TurnRequest LLMSelection accepts the field
(validated against VALID_REASONING_EFFORTS, old two-ID payloads unchanged),
the generated web contracts are regenerated, and ChatStateAdapter's
asLLMSelection restores a legal override instead of dropping it.

The composer gains a selector beside the model picker, offering only the
levels the selected model supports (live supported_reasoning_efforts or
the provider/model tables) narrowed to the wire vocabulary, hidden when
the model has none. The choice persists on the conversation's
llm_selection, so the next send uses it without a backend restart and
other conversations are unaffected; switching models resets the override.
Precedence stays conversation override -> profile/model default ->
provider default, and the context-budget readout reports the effective
effort beside the model when one was used.
2026-11-09 20:47:08 +08:00
evan188199-tech
5177b4d48f fix: keep first-chat tokenizer acquisition local and nonwaiting 2026-11-09 00:42:38 +08:00
KaiChan
fefa6c0437 fix(runtime): isolate indexless streamed tool calls 2026-11-06 19:16:02 +08:00
stefanielizeth73-art
3f943e14c8 feat(agent-loop): configure bounded reasoning-budget recovery 2026-11-03 00:12:00 +08:00
Bingxi Zhao (Frank)
9aadac3e3b merge: integrate current dev with modular installation 2026-10-28 01:23:48 +08:00
Bingxi Zhao (Frank)
fbab59acbf feat: modularize installation and enforce feature dependency boundaries 2026-10-28 01:02:29 +08:00
Bingxi Zhao (Frank)
1abffcf0e7 Merge remote-tracking branch 'origin/dev' into HEAD 2026-10-27 21:43:24 +08:00
Bingxi Zhao (Frank)
e347c0c2e0 fix: preserve tutoring replies and stabilize preview runtime
Keep learner-facing explanations visible across finish checks, persistence, and replay. Remove mastery prose heuristics and prioritize learner objections.

Coordinate service shutdown and descendant cleanup, and preserve video lesson identity and playable results across chat completion and reload.
2026-10-27 17:58:46 +08:00
nandanadileep
6299f773c2 fix: apply prompt caching in agent loop _call_llm 2026-10-27 00:49:02 +00:00
Bingxi Zhao (Frank)
9d822fcdf0 fix(ci): align preview fixtures and formatting with current contracts 2026-10-27 01:44:57 +08:00
Bingxi Zhao (Frank)
6bbcc00c55 Merge dev into preview, preserving preview features
Integrate dev fixes with preview's Python/TypeScript schedulers, chat queue, learning navigation, and live turn persistence.
2026-10-27 01:16:58 +08:00
Bingxi Zhao (Frank)
28c11e2ae8 feat: update notes, chat interactions and workspace UI on preview
Remove course pages, APIs and the course_study capability. Add anchored note
threads and reviewed learning-block generation, queued and withdrawable chat
messages, quote attachments, side chats, and the calendar/favorites/navigation
updates.

Keep preview's existing backend architecture. Wire the new features through
its Python application and existing chat engine, retain legacy selected-text
requests, persist mid-turn messages in replay, and restore note context when
regenerating. Leave stored user data intact.

Validate frontend contracts, dependency boundaries, types, 1290 node tests,
840 rendered tests, lint, localization and the production build. Exercise
session/notes/API regressions, 53 chat-engine tests and 20 Python/native
integration tests with isolated runtime data.
2026-10-26 22:13:34 +08:00
Bingxi Zhao (Frank)
8b73efbaeb Merge PR #1958: stabilize cached prefixes with bounded sources and complete summary accounting 2026-10-19 00:59:30 +08:00
Bingxi Zhao (Frank)
1497994c9f Merge PR #1938: bound tutoring history and retain exact recall when condensation fails 2026-10-19 00:57:48 +08:00
Bingxi Zhao (Frank)
9aae961412 Merge PR #1957: separate private source evidence from explicit public presentation 2026-10-19 00:53:44 +08:00
Bingxi Zhao (Frank)
3196b6d792 Merge PR #1954: prepare source evidence through a generic capability prerequisite contract 2026-10-19 00:48:43 +08:00
Bingxi Zhao (Frank)
ba899ffc68 Merge PR #1939: review outline changes before atomic commit 2026-10-19 00:38:00 +08:00
Bingxi Zhao (Frank)
61719b18de Merge PR #1952: verify teaching delivery alongside durable feedback 2026-10-19 00:36:32 +08:00
Bingxi Zhao (Frank)
e8c0b1eed5 Merge PR #1962: count complete projected requests in context guard 2026-10-19 00:31:25 +08:00
Bingxi Zhao (Frank)
399297e7f0 feat: preserve TypeScript engine migration and workspace updates 2026-10-18 23:09:10 +08:00
Bingxi Zhao (Frank)
857a82e74a feat(notes): add block notebooks with inline reviews and linked favorites
Add rich text and learning blocks, media uploads, page trees, and revisioned notebook storage. Present AI suggestions at their target blocks with durable accept and dismiss actions.

Unify saved outputs as Favorites with typed expandable blocks, stable source links, atomic batch insertion, nesting, dragging, and undo/redo.

Validation: 99 frontend tests and 99 backend tests pass in an isolated snapshot, along with TypeScript, scoped ESLint, dependency architecture, and locale parity checks.
2026-10-17 23:15:23 +08:00
wangkai
87a0317255 feat(agent-loop): let a context checkpoint carry replaceable state
A checkpoint may now carry an optional `state` next to `summary`. The fold
keeps appending summaries before the boundary as before and places `state`
in one system message after it, so the next fold replaces the state instead
of stacking stale copies. Checkpoints without `state` behave exactly as before.
2026-10-15 13:00:03 +08:00
Bingxi Zhao
0e784d5080 Merge pull request #1910 from YizukiAme/codex/fix-1909-image-compaction
fix(session): budget projected image replay before compaction
2026-10-15 03:23:49 +08:00
Bingxi Zhao
d348b42336 Merge branch 'dev' into codex/fix-1909-image-compaction 2026-10-15 02:04:18 +08:00
Bingxi Zhao
8b2e62accd Merge branch 'dev' into fix/agent-loop-preserve-multimodal-instruction 2026-10-15 02:04:12 +08:00
cgycorey
8df56e7dfe fix(agents): count the full request in the context-window guard
The guard sized the request from message content alone. It ignored
assistant tool_calls arguments and the tool schemas sent with the call,
so a request over the window could go out untrimmed.

- Count each message with the counter history planning uses, leaving out
  the _context_snapshot key that _call_llm strips before sending.
- Pass the call's tool_schemas into the guard. The forced-finish round
  sends none, so it passes none.
- Keep a running total while tool results are snipped instead of
  re-estimating the whole request after every snip.
- Log a warning when nothing is left to trim and the request still does
  not fit, rather than passing it silently.

With the call's tool schemas, the 8k reproduction from #1961 now trims all
three tool results, taking the request from 10435 to 6514 tokens against a
7372-token budget.

Refs #1961
2026-10-14 10:18:59 +01:00
zane-i
00b92f20c6 fix(session): stop the rolling summary from breaking the prompt cache
The summary was prepended inside the replayed history, so every
compaction rewrite changed bytes at the head of the request and threw
away the whole cached prefix behind it. Measured on a six-turn session
on a custom OpenAI-compatible route: the turn that rewrote the summary
dropped the shared prefix to one message and ran 21,629 prompt tokens
for 5,888 cached (27.2%).

Deliver it where the runtime-snapshot machinery already puts per-turn
context: as a trailing role=user message tagged _context_snapshot. A
rewrite is then a pure append, and an unchanged revision is a no-op.
replay_history no longer injects the summary, which is what kept it
mid-request whatever position it was given.

Two smaller fixes ride along, both in the same summary path:

* The summariser's scratchpad leaked into compressed_summary when the
  route emits reasoning inline. The stored summary was 6,933 characters,
  half of them the model's drafting monologue under an unclosed think
  tag, and the real summary was truncated by it. clean_thinking_tags
  cannot be used here - it deletes through end of text for an unclosed
  block - so the tag is honoured only when it is closed, and an unclosed
  one is cut at the first heading.

* _model_tokens counts the summary the way the request carries it.

The two regression tests that pinned the summary inside model_history
now assert the new delivery: the history starts at the oldest retained
turn and the summary still reaches the model.
2026-10-13 23:46:59 +08:00
yepyhun
755686264d fix(mastery): separate source inspection from assessment delivery 2026-10-13 13:49:35 +02:00
yepyhun
3175b812e2 fix(mastery): make source delivery demand-driven and preserve partial teaching 2026-10-13 12:33:44 +02:00
yepyhun
cc079776c4 fix(mastery): bind teaching records to visible delivered explanation 2026-10-13 08:29:46 +02:00
Bingxi Zhao (Frank)
3cbecb2479 feat(workspaces): add scoped instructions and refine learning UI 2026-10-12 19:29:47 +08:00
yepyhun
c510b13363 feat(mastery): add reviewed outline previews and retry-safe commits 2026-10-12 11:23:32 +02:00
yepyhun
499e6bc75f feat(mastery): bound tutoring memory with exact branch recall 2026-10-12 11:16:34 +02:00
Fancie-Personal
4826ae980a fix(agent-loop): keep content parts when appending a loop directive
`_append_loop_instruction` appended a recovery directive by rebuilding the
trailing user message as a string. A user message can carry content parts —
chat PDF attachments add image blocks beside the text — and `str()` on that
list folds every `data:...;base64,` URL into prompt text, so the next round
sends image bytes to the provider as language tokens instead of images.

A scanned 7-page PDF (whole-page JPEGs harvested as embedded figures) turned
into a ~5.9 MB prompt string: the image-aware context counter reported
4,014,309 tokens for the round against a 1M window, the provider answered
400 InvalidParameter, and the turn ended on the empty-response fallback.

The directive now extends the message's own text part, or appends a text part
when the message holds only images. Image parts, their order and the durable
model turn are unchanged; only the text grows.

Reached whenever a round ends with nothing to replay: an empty finish, or one
whose stream carried no text, reasoning or tool call.
2026-10-11 20:12:57 +08:00
YizukiAme
e747f28705 fix(session): budget projected image replay before compaction 2026-10-10 00:33:40 +08:00
Bingxi Zhao (Frank)
1e7eef0e9a feat(research): add grounded scientific primitives and scoped private MCP origins (#1629) 2026-10-08 10:05:38 +08:00
Bingxi Zhao (Frank)
2350ea2dba feat(mastery): complete source-grounded visual practice and evidence (#1611)
Bind original visual sources and keys to supported tasks; verify accepted model pixels, preserve cues/assistance and canonical attempts, keep uncertainty ungraded, expose challenge/repair, and separate required visual evidence from generic text mastery.
2026-10-08 05:25:05 +08:00
Bingxi Zhao (Frank)
64bc0d8e7c feat(learning): expose a durable workspace journal overview (#1407)
Adapt the journal foundation from PR #1226 and add a read-only mission, handoff and confirmed-record panel. Share its snapshot with turn injection, preserve corrupt files, and serialize worker writes.

Co-authored-by: ZQR1101 <278034003+ZQR1101@users.noreply.github.com>
2026-10-08 03:11:15 +08:00