33 Commits

Author SHA1 Message Date
Oikantik Basu
9e5a4e64c9 fix: preserve thinking-off settings on research outline retries (#3134) 2026-12-01 09:34:04 +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
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
0261ecac1f fix: move per-block research state out of the cached system prompt 2026-11-30 03:47:50 +08:00
mpichini1
6bf7c631e4 fix: preserve PageIndex sources in report citations 2026-11-13 19:49:05 +01:00
Alex Castillo
15a6864a64 fix(research): price dated gpt-4o-mini names with the mini rates
get_model_pricing returned the first dict key found inside the model
name, so gpt-4o-mini-2024-07-18 and openai/gpt-4o-mini matched gpt-4o
and were billed at the full model's rates. Pick the longest matching
key instead.
2026-11-03 16:06:19 -05:00
Bingxi Zhao (Frank)
cf44400fc8 fix(research): identify unwritten report parts on failure (#1514) 2026-09-27 05:02:08 +08:00
Bingxi Zhao (Frank)
9d3e7c3102 fix(research): resume ask_user replies from shared loop helpers (#1600) 2026-09-27 04:52:21 +08:00
Bingxi Zhao (Frank)
ffbe0a541b fix(agentic): replay reasoning in repair and report retries 2026-09-23 12:30:01 +08:00
Frank_zhu
6fbed6c28e fix(research): recover report labels on finished reply (#1514)
Keep the streaming 64-char probe strict, then re-read a finished report
reply so an unclosed/over-wide fence or a matching ## n. heading no
longer kills the turn. Raise report_section max_tokens to 12000 and
turn reasoning off for report prose so first attempts stop starving.
2026-09-21 10:27:09 +08:00
Bingxi Zhao (Frank)
c31bed8aeb refactor(llm): one rule for a structured call a reasoning model starved
Four defects this month were the same failure: a step asks a model for a
whole payload in one shot, the model spends its whole max_tokens on
hidden thinking, and the provider returns a truncated body or none at
all — with no error. Book's spine collapsed to a single "Overview"
chapter (#1316), the quiz plan emitted zero templates (#1318), the
non-streaming path handed the scratchpad back as the answer (#1352).

Each fix grew its own retry. Book got `book/json_retry.py`; question got
`LabeledStepResult.reasoning_only`; research got nothing, so its
decompose step still degraded a topic to one sub-topic in silence, and
its report outline still lost the whole report structure.

Moves the rule out of `book/` — it was never Book's — into
`services/llm/structured_retry.py`, and points it at the streaming-side
detector so the two halves read as one rule: two ways to notice a budget
spent on hidden tokens, one remedy, which is to ask again with thinking
turned down.

Applies it to research's two one-shot payloads, which needed the step
wrapper to accept a per-call reasoning effort the way question's already
did.

The generic entry point takes the caller's own `is_usable` rather than
imposing the object shape. Research's decompose accepts a bare array of
sub-topics; judging that unusable would have retried a good answer and
then discarded it — a regression the object-shaped helper would have
caused as the only entry point. The object form still guarantees a dict,
because its callers index the result directly.

6902 passed, 24 skipped.
2026-09-11 12:43:41 +08:00
Bingxi Zhao (Frank)
3d2648d01b fix(research): stop the settings layer shadowing the tool policy defaults
The follow-up to #1357 moved ResearchPipeline's defaults to a 240s
ceiling with retries off, but `_MAIN_YAML_RUNTIME_DEFAULTS` still held
60s / 3 retries. That table is the fallback used when a research
settings payload is written, so a user who merely opened research
settings and saved — without touching either field — persisted 60/3 into
main.yaml and the pipeline default became unreachable from then on.

Same shape as #1316, where a section missing from the config map meant a
4096 token budget no user could raise. A default that a layer above
silently overwrites is not a default, so pin the invariant in a test
rather than leaving the two numbers to drift again.
2026-09-10 23:56:42 +08:00
Bingxi Zhao (Frank)
253dc0b284 follow-up to #1357: a ceiling for a stalled provider, not for a slow tool
60s cancels research work that was going to finish — one rag call against
a LightRAG or GraphRAG index makes its own LLM calls before returning, and
search-then-fetch waits on someone else's site — and each of the three
retries then pays the full timeout again. 240s is the ceiling
geogebra_analysis already uses for the same reason; retries default to 0 so
only a caller who knows its tools are flaky, not slow, pays for a second
attempt. Both remain configurable under researching.

Pins the pair in a test: the policy tests pass whatever they configure, so
nothing held these two numbers.

(cherry picked from commit 389fe3f0daf1abb4eddc87be84485d47982b84a3)
2026-09-10 23:55:18 +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)
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)
02ba56793e chore: checkpoint backend stabilization workspace 2026-09-01 21:28:15 +08:00
zhou2030109-glitch
bb6b0cd629 fix: make deep research resilient to interrupted streams 2026-08-27 10:11:00 +08:00
Bingxi Zhao (Frank)
97574b5236 fix: three defects on the paths this week's PRs touched
Found by an adversarial pass over the merged changes.

**A tool call could run under another call's name and arguments.**
``_ToolCallBuffers.add`` registered every buffer under the placeholder
item id ``fc_0``, which providers that omit ``item.id`` all share, and
``response.output_item.done`` looked buffers up by that same placeholder.
A ``done`` event for a call that was never announced therefore resolved to
whichever unrelated call last claimed it. Reproduced: a second call to
``list_kb`` was dispatched as ``delete_kb`` carrying the first call's
``{"kb": "secret"}``. The placeholder is a display fallback, not an
identity — never alias it, never look up by it.

**A blocked CDN froze every HTML visualization.** The iframe height
bridge attached its observers on ``DOMContentLoaded``, but ``injectKaTeX``
adds deferred script tags, and deferred scripts must all run before that
event fires. With jsdelivr unreachable the observers never attached and
every visualization sat at its initial height. The bridge is injected just
before ``</body>``, so it can gate on ``document.body`` instead and attach
before the CDN fetch resolves.

**RAG citations dropped their sources.** ``_extract_rag_citation`` was the
only extractor not handed ``tool_metadata``; it re-parsed ``raw_answer``,
which is the prose shown to the model, not JSON. Every RAG pipeline
normalises its retrieval into ``metadata["sources"]`` — already the shape
``_rag_source_payload`` reads — so prefer it and keep the answer parse as
the fallback. This is the user-visible half of #808 that normalising the
payload alone did not restore.

Also hoist the Gemini "minimal, not none" families beside
``_PROVIDER_DEFAULT_OFF_PATTERNS``, whose docstring calls itself the single
source of truth for exactly this knowledge.
2026-08-12 17:28:56 +08:00
Bingxi Zhao (Frank)
eec4134d15 fix: normalize RAG citation payloads (#808) 2026-08-12 16:11:29 +08:00
szzhoujiarui
47b713d36e fix(research): mount read-only Obsidian tools instead of rag for vault KBs (#756)
* fix(research): mount read-only Obsidian tools instead of rag for vault KBs

When the selected knowledge base is a connected Obsidian vault, the
research block loop now:

- resolves KB metadata at construction and records the server-side vault
  path (no RAG usage audit);
- suppresses the rag auto-mount (has_kb=False) and exposes the three
  read-only Obsidian tools obsidian_search / obsidian_read / obsidian_list;
- injects _vault_path server-side, overwriting any model-supplied value;
- treats the Obsidian tools as citable so their evidence feeds the
  citation manager and Phase 4 reporting;
- renders an Obsidian-specific system note (en/zh) instructing read-only
  vault retrieval instead of rag.

Indexed KBs, no-KB, and unresolvable references keep their existing
behaviour. Closes #752

* fix(research): preserve Obsidian citation context

---------

Co-authored-by: szzhoujiarui-sketch <szzhoujiarui-sketch@users.noreply.github.com>
2026-08-06 22:07:26 +08:00
Santh
5449b2dc05 fix(research): parse first JSON value when adjacent values follow (#680)
extract_json_from_text used a greedy brace match, so {"a":1}{"b":2} returned None.
2026-07-24 16:04:47 +08:00
Bingxi Zhao (Frank)
3b823ae5f7 minor fixes 2026-06-29 23:06:30 +08:00
Bingxi Zhao (Frank)
46093e5e2b update msg 2026-06-11 20:03:34 +08:00
Bingxi Zhao (Frank)
6153d8c092 release: v1.4.0 — release notes, version bump, repo hygiene
- Add assets/releases/ver1-4-0.md covering deltas since v1.4.0-beta
  (reasoning_effort normalization, tool-schema fallback, restart-safe
  turn runtime, frontend placeholder hardening, CLI chat REPL config).
- Bump deeptutor/__version__ to 1.4.0.
- Update README Releases section: v1.4.0 at top, install opt-in note
  updated for stable.
- Fix pre-existing pre-commit failures so the v1.4.0 cut runs clean:
  bandit B324 (mark _sha1 as non-security), mypy no-redef in
  document.py / line_doc.py, mypy arg-type/assignment in
  snapshot/adapters.py, mypy assignment + arg-type in
  services/memory/settings.py, mypy func-returns-value on
  set.add idiom in deeptutor_cli/init_wizard.py.
- Apply ruff format / prettier sweep across the repo.
- Remove stale workspace + i18n env example + playwright captures
  already cleaned locally; ignore .playwright-cli/ going forward.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 21:09:22 +08:00
Bingxi Zhao (Frank)
23ca3024be refactor(agents): rebuild Deep Research / Deep Solve / Question on agentic engine
Replaces three bespoke multi-agent pipelines with orchestrators on top
of a shared agentic-engine primitive set (core/agentic/: labeled_step,
loop, tool_dispatch, usage, client). Each capability now lives in one
pipeline.py file with one pipeline.yaml prompt.

- Deep Research: Rephrase (ask_user loop) -> Decompose (OUTLINE) ->
  Research blocks (THINK/TOOL/APPEND/FINISH per topic, dynamic queue
  preserved) -> Reporting (OUTLINE/INTRO/SECTION/CONCLUSION).
  CitationManager and the dynamic topic queue are kept.
- Deep Solve: Pre-retrieve (KB-only, QUERIES/rag/SUMMARY) -> Plan ->
  per-step THINK/TOOL/FINISH/REPLAN loop with back-edge to Plan ->
  Synthesize. Step FINISH text flows into the next step's context.
- Question: coordinator + pipeline replace generator / idea_agent /
  models, with new history.py and mimic_source.py helpers.

Removed: research/agents/, research/research_pipeline.py,
research/prompts/{en,zh}/*.yaml (legacy multi-agent prompts);
solve/agents/, solve/memory/, solve/utils/, main_solver.py,
session_manager.py, tool_runtime.py and old prompts;
question/agents/{generator,idea_agent}.py, example.py, models.py,
old prompts; api/routers/solve.py (capability owns its own routing).

Adds shared agents/_shared/tool_composition.py for cross-pipeline
tool wiring. Updates deep_research/deep_solve/deep_question
capabilities to dispatch through the new pipelines.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 18:03:44 +08:00
Bingxi Zhao (Frank)
72bcdd77d8 prepare v1.3.9 release 2026-05-09 02:53:14 +08:00
Bingxi Zhao (Frank)
6428458049 chore: prepare v1.2.5 release 2026-04-25 22:08:44 +08:00
Bingxi Zhao (Frank)
77f29cbcc7 fix lint 2026-04-23 19:29:16 +08:00
Bingxi Zhao (Frank)
593ddba3fb feat(co-writer): add multi-doc co-writer workspace with backend storage
- Add co-writer storage module and API router for document persistence
- Restructure co-writer page to per-doc routing ([docId]) with sidebar recent list
- Wire CoWriterRecent into sidebar shell and AppShellContext
- Tidy notebook prompts, facade, path service, and builtin tools wiring
- Refresh tests (add missing __init__.py, drop obsolete app_facade test)
- Add favicon/apple-touch-icon assets and minor i18n cleanup

Made-with: Cursor
2026-04-20 19:46:41 +08:00
Bingxi Zhao (Frank)
100576da69 release: v1.1.2 — schema-driven channels, secret masking, RAG simplification, KB-consistency hardening
* TutorBot Channels tab is now schema-driven across every built-in & plugin channel
  (GET /api/v1/tutorbot/channels/schema), with per-field secret reveal toggles.
* Channel secrets are masked end-to-end; raw values only surface via the explicit
  ?include_secrets=true edit-form route. PATCH validates ChannelsConfig at the API
  boundary and returns 422 on bad payloads. reload_channels is serialised by an
  asyncio.Lock and records last_reload_error for the UI.
* Collapsed services/rag/ to a single LlamaIndex pipeline: removed ~2.6k lines of
  unused components/* + pipeline.py + types.py + utils/ + parsers/. rag_provider
  is now a stub; legacy values silently coerce to llamaindex.
* Centralised file routing into services/rag/file_routing.py (FileTypeRouter /
  DocumentType / FileClassification); dropped per-provider extension helpers.
* Defensive RAG/KB consistency: deep_solve / deep_research strip rag/kb when no
  KB is attached; SolveToolRuntime + ResearchPipeline + DecomposeAgent
  short-circuit instead of falling back to non-existent default KBs (DE-all,
  ai_textbook).
* Externalised AgenticChatPipeline prompts into agentic_chat.yaml (zh + en).
* Added Thai README (#337).
* New test modules: file_routing, knowledge_base_config, channel_schema,
  channel_secrets, rag_consistency, research_pipeline_rag.

Full notes: assets/releases/ver1-1-2.md

Made-with: Cursor
2026-04-18 11:33:53 +08:00
Bingxi Zhao (Frank)
9c18bf0705 codebase cleanup and decoupled, introduce cli operation 2026-03-13 20:42:16 +08:00
Bingxi Zhao (Frank)
91197f3729 chore: deeptutor 2.0 2026-03-13 01:47:38 +08:00