20 Commits

Author SHA1 Message Date
lipeh1
803c4a4a35 fix: preserve empty reasoning in quiz tool continuations (#2800)
* fix: preserve empty reasoning in quiz tool continuations

* test: cover empty reasoning in assistant tool messages

---------

Co-authored-by: lipeih <lipeihan@eazytec.com>
2026-11-28 18:22:57 +08:00
KaiChan
fefa6c0437 fix(runtime): isolate indexless streamed tool calls 2026-11-06 19:16:02 +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
yepyhun
755686264d fix(mastery): separate source inspection from assessment delivery 2026-10-13 13:49:35 +02:00
yepyhun
136c41fb71 test(agentic): reproduce schema-valid null rejection 2026-10-13 00:34:53 +02:00
Bingxi Zhao (Frank)
ffbe0a541b fix(agentic): replay reasoning in repair and report retries 2026-09-23 12:30:01 +08:00
Bingxi Zhao (Frank)
4e2f088548 merge: bring 19 reviewed PRs from origin/dev into dev
Resolves two collisions with the fixes committed locally tonight:

* book/blocks/_llm_writer.py — #1366 threaded a reasoning_effort
  through llm_json while 5ac8e2c9 replaced this file's private
  _json_has_expected with the shared json_payload_is_usable.
  Taking either side alone breaks: origin/dev's calls a helper that no
  longer exists, ours drops the caller's explicit effort. Kept the shared
  helper and the threading, and the retry now reuses an explicitly given
  effort so a round deliberately run without thinking cannot re-enable it.

* runtime/agentic/tool_dispatch.py — #1357 added tool_timeout /
  tool_max_retries to execute_tool_call in the same parameter list where
  4e816d79 renamed unknown_error_message_factory (tool) to
  tool_error_message_factory (tool, error). Both are needed: the
  dispatcher already passes the timeout pair through, and every call site
  in the tree now uses the renamed factory.
2026-09-10 23:52:04 +08:00
evan188199-tech
30e0f7c3a2 fix(research): enforce tool timeout and retry policy (#1357)
Co-authored-by: XZH <cto@xzh.ai>
2026-09-10 23:45:30 +08:00
Bingxi Zhao (Frank)
4e816d7933 fix(tools): tell the model why a tool failed, not that it failed
Stop the Ollama a vector KB embeds against, ask a question, and the model
is told "An unknown error occurred while executing rag." The adapter had
already written the answer — `Cannot connect to Ollama at
http://localhost:11434. Make sure Ollama is running. Start it with:
ollama serve` — and the dispatcher was holding it (#1356).

`unknown_error_message_factory` took the tool name and nothing else, so
no caller could have done better. Four capabilities each wrote their own
message from that one argument and three of them called the result
unknown; the fourth, pageindex, restated the dispatcher's own default
minus the cause. The name was the bug: it presumed a cause the runtime
always had.

It is now `ToolErrorMessageFactory`, `(tool, cause) -> str`, and the key
plus the English wording live once in `tool_error_message_factory`, which
each capability wraps around its own `_t`. Capabilities keep their
translations and can no longer keep the cause out of them. pageindex
passes nothing and takes the default. A bundle predating the new
`notices.tool_error` key falls back to English rather than to silence
about what went wrong, which is the reason the fallback carries the cause
too.

This is the same shape as read_skill answering "skill not found" when the
skill resolved and only the file was missing (#1347): a failure the
caller cannot see has no way out, and the model spends its rounds
inventing one.

The regression test is the reporter's turn — a `rag` call raising the
real adapter error — and asserts the endpoint and the remediation reach
the role=tool message.
2026-09-10 23:00:11 +08:00
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)
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
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)
02ba56793e chore: checkpoint backend stabilization workspace 2026-09-01 21:28:15 +08:00
ZQR1101
e6f41b88a9 fix(agentic): distinguish empty vs missing tool args (#1101)
When a required string key is present but blank, tell the model it sent an empty value instead of framing it as omitted — thinking models otherwise retry the identical call. Also clarify obsidian_create_note.content must be non-empty.
2026-08-30 19:37:32 +08:00
Bingxi Zhao (Frank)
bd80a4d28a release: v1.5.17
Partners stop being a deployment-wide admin resource and become
per-user: three nested rights (manage / use / neither) replace the
blanket admin gate on the router, each member can build and own their
own, and every person's conversations with a partner stay private to
their account. Grants keep working and now offer only admin-managed
partners. Channel runtime state moves from one directory per channel to
one per partner — copied, not moved, and only when its owner is
unambiguous — so two partners can finally run the same channel.

Around that: a knowledge base can track GitHub repositories and re-sync
their Markdown (#903); Antigravity CLI joins My Agents now that Gemini
CLI is retired (#828); personal WeChat signs in from a QR code drawn in
the browser instead of the server log (#951); a chat account can be
linked to a DeepTutor account with /link; containers re-apply the extras
they declare instead of losing them at compose down (#762); and
`deeptutor doctor` answers whether a workspace is ready to run (#959).

Reliability, largely from community PRs: embeddings survive a
rate-limited provider through key rotation, a retry budget and a global
throttle (#962); MinerU parsing and code execution work on Windows
(#844, #964); indexing fails bounded instead of hanging (#946); MinerU
page-layout blocks stop being indexed as content (#949); voice uploads
carry a MIME the transcription API accepts (#945); and reasoning effort
can be overridden per conversation (#641).

Release plumbing: notes in assets/releases/ver1-5-17.md, v1.5.13
archived, __version__ 1.5.17, README Releases row and all eleven
translations synced.

Two defects found by the release gate and fixed here:

- Six partner routes — the four channel-onboarding endpoints and both
  WeChat QR endpoints — kept the _auth-only mount they had inherited
  from the blanket admin gate, so any signed-in account could start a
  QR login for someone else's partner and write a bot token into its
  channel config. All six now declare _MANAGEABLE, and a sweep test
  asserts no {partner_id} route is left ungated.
- A configured api_key became `str | list[str]` when key rotation
  landed, but ten call sites pass it somewhere that takes one key; a
  list would have rendered into an Authorization header verbatim.
  keypool.primary_api_key reduces at each boundary.

Gates: pre-commit (all 15 hooks), ruff check + format, pytest
5276 passed, web 605 node tests, docs build.
2026-08-25 02:24:35 +08:00
Bingxi Zhao (Frank)
9e4233c3ae fix(chat): assign streamed tool-call ids instead of appending them
A router in front of an OpenAI-compatible provider re-sends the complete
`id` on every delta chunk rather than only on the first. The chat loop and
the explore capability appended it, so the id grew one copy per chunk —
#937 observed 551, 754, 870, 1566, 9715, 17864 and 47241 characters. Past
the provider's own 64-character ceiling every round died with HTTP 400
`Invalid 'messages[i].tool_calls[0].id': string too long`, the
forced-finish call died the same way, and the turn surfaced as "I could not
produce a useful response from the model output."

The report named one site and declared `name` correct as-is. There were two
sites, and both had the identical defect on `name`, which a repeat corrupts
into an unresolvable `toolnametoolnametoolname` — latent for that
reporter's gateway, fatal for any gateway that repeats the name.

Rather than restate the per-field rule a third and fourth time, converge
the three core-layer sites (chat loop, explore capability, labeled step)
onto one accumulator that states it once: `id` and `name` arrive whole and
are assigned, `arguments` arrives in fragments and is concatenated. That
rule is not new — it is what the services-layer provider's `_accum_tc` has
always done, which is the evidence that assigning `name` is safe across
every gateway users have configured. That accumulator stays where it is:
it reads deltas that may be plain dicts, so folding it in would widen the
blast radius without fixing anything.

Coercing a missing `index` to 0 also removes a latent crash in the labeled
step runner, where a `None` key made the final `sorted()` raise as soon as
one real index appeared.
2026-08-21 16:20:13 +08:00
Bingxi Zhao (Frank)
96d6df9eb1 release: v1.5.13
Book is the bulk of this one. Compilation outlives the request that
started it, so a bus owned by that request dropped every background event
and "watch your book being written" degraded into a frozen page; the
stream is now owned per book by the process and survives a refresh or a
reconnect. Reading progress is finally recorded — `visited_page_ids` and
`bookmarked_page_ids` had been declared but never written for the life of
the feature — and rolls up into a completion score and weak chapters. A
book can also leave the app now, as one self-contained Markdown document,
with non-ASCII titles surviving the download.

Two scheduling defects that were invisible in production are fixed: the
same page compiled twice concurrently (billed twice, one result
discarded), and a book grinding on through a provider outage until every
chapter was half-generated. The source sweep is bounded and allocated
round-robin rather than spent on the first few knowledge bases, and
retrieval now tells indexed bases from connected pointers, so an Obsidian
vault or a remote IMA library no longer contributes zero while looking
like a source with nothing relevant. Confirming a spine shows a live
per-chapter estimate derived from the Section Architect's own templates.

Also here: three home starter suggestions built from memory recall,
mastery-path handoff moved into one module that changes lease, session
preference, and live turn together, and account-level Tencent IMA
credentials with the per-KB pair still winning.

Notes: assets/releases/ver1-5-13.md

This commit also carries the README prose sync, the eleven translated
READMEs, the release-notes archive sweep, and the version bump. Two gate
fixes ride along: the `Stamped` protocol is declared read-only so the
frozen `EntityStamp` satisfies it, and six GraphRAG adapter tests that
reached a deep `graphrag` import without guarding it now skip like their
four neighbours instead of failing where the extra is not installed.
2026-08-17 11:22:26 +08:00
Bingxi Zhao (Frank)
b28a1a7b01 fix(chat): reject tool calls whose required arguments never arrived (#779)
Under a large tool surface and long history, providers intermittently emit
a native function call with empty ``arguments`` even though the schema marks
fields required. The call was dispatched anyway, so the tool did the
rejecting: ``exec`` raised "requires a non-empty command", ``write_note``
answered "Unknown mode ''". Neither reads as "an argument is missing", so
the model re-emitted the same malformed call until the loop budget ran out
— one report saw 5 of 7 write_note calls arrive empty and retry 5-7 times.

A guard in front of dispatch turns that into one self-correcting round: the
call never runs, and the role=tool body names the missing arguments and
their accepted values (including enums, which is what turns "Unknown mode
''" into a one-round fix).

The rules stay narrow so nothing that used to work stops working: a
parameter carrying a default is not required, empty collections are left
alone, server-injected kwargs count as supplied, and an unknown tool name
still reaches the registry that owns that error. Every required argument
across the builtin tools is one the tool would have raised on anyway.
2026-08-07 21:09:05 +08:00
Bingxi Zhao (Frank)
740ec413a0 release: v1.5.7
Per-account MCP Services and CLI Apps — the two ways a deployment plugs in
tools DeepTutor never shipped — plus the isolation that makes them safe on a
shared install.

- MCP Services: a 45-entry curated store of hosted servers each account
  installs for itself, OAuth 2.1 (PKCE + dynamic client registration) for the
  servers that require it, static keys held by reference and resolved in memory
  at connect time, stdio refused for self-service. Settings no longer
  configures MCP; /settings/mcp redirects to the store.
- CLI Apps: 101 tools snapshotted from the two CLI-Anything registries.
  Installs are admin-only, the registry's install_cmd is parsed into an argv we
  build rather than executed, npm install scripts are forced off, and 66
  first-party entries are pinned to one reviewed commit. Apps land in
  data/cli-apps, one environment each, mounted read-only into the runner.
- Credentials that authorise a person move to data/system, the one branch the
  exec sandbox never mounts: Codex tokens relocate themselves on first use
  (refusing to follow a symlink), per-user MCP configs and keys land beside
  them.
- Grants gain a cli_apps whitelist with the same deny-by-default posture as
  MCP tools; a per-turn registry view keeps one owner's provider tools out of
  the process-global registry and refuses an unauthorised tool at execute, not
  just in the manifest.
- The composer reports what filled this turn's context window, a gutter rail
  jumps back through long conversations, and the workspace collapses to a
  drawer on small screens.
- The composer keeps focus after sending and across tab switches (#720);
  released images carry provenance and SBOM attestations (#722).

README prose, all ten translated READMEs, and the docs-site pages that named
Settings → MCP are updated to match. Release notes:
assets/releases/ver1-5-7.md
2026-07-31 00:25:48 +08:00
Bingxi Zhao (Frank)
46093e5e2b update msg 2026-06-11 20:03:34 +08:00