Commit Graph

763 Commits

Author SHA1 Message Date
Bingxi Zhao (Frank)
c54743bfb0 improve chat 2026-05-28 22:01:26 +08:00
Bingxi Zhao (Frank)
db41c574a1 refactor: centralize Gemini default-off reasoning in reasoning_params
Follow-up to #490. The PR inlined the "disable thinking for Gemini 2.5/3"
gate in 5 places across 3 files. This commit collapses them to one
registry and three thin call sites.

Changes:

* `services/llm/reasoning_params.py`: new `_PROVIDER_DEFAULT_OFF_PATTERNS`
  registry + `default_reasoning_effort_for(provider, model)` public helper.
  `build_openai_compatible_reasoning_kwargs` now consults the registry, so
  the openai-compat path (which lost its inline gate during the #490 merge
  conflict resolution) is restored via the helper.

* `services/llm/executors.py` (sdk_complete + sdk_stream) and
  `services/llm/cloud_provider.py` (_openai_complete + _openai_stream) now
  call `default_reasoning_effort_for(...)` instead of inlining the
  ('gemini-2.5', 'gemini-3') startswith check.

* Use substring (not startswith) match so `models/gemini-2.5-flash` is
  also covered — some OpenAI-compat clients prefix model ids with `models/`.

* `services/config/loader.py:get_agent_params`: when a module's section is
  missing from the user's stale `agents.yaml`, fall back through
  `DEFAULT_AGENTS_SETTINGS` before the global `(0.5, 4096)` default. This
  lets the `capabilities.visualize` default (`max_tokens=16384` from #490)
  reach existing installs, not just fresh ones.

* `capabilities/visualize.py`: hoist the duplicated lazy
  `from deeptutor.agents.visualize.models import ReviewResult` import
  from two branches into the top of `run()`.

Tests:

* `tests/services/llm/test_reasoning_params.py` — 17 new cases covering
  Gemini 2.5/3 + `models/` prefix + case-insensitivity + the legacy
  Gemini 1.5/2.0 / other-provider untouched paths + the explicit-override
  takes-precedence rule.
* All 107 tests in `tests/services/llm/` still pass; 5 pre-existing
  `test_chat_params_config` failures (8192 vs 8000 drift) are unrelated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 18:00:08 +08:00
Bingxi Zhao (Frank)
44564b077b Merge pull request #490: fix(visualize): unblock Gemini 2.5+ and harden Visualize pipeline
Squash-merge of #490 (skinred78) with two non-trivial conflict resolutions:

* `openai_compat_provider.py`: PR inlined reasoning_effort logic that has since
  been refactored into `build_openai_compatible_reasoning_kwargs`. Keep the
  helper call; the Gemini default-down will be folded into the helper in a
  follow-up commit instead of duplicating it inline.

* `capabilities/visualize.py`: i18n was applied to the review-stage messages
  after the PR forked. Kept the new try/except review-fallback structure but
  routed all three messages through `i18n.t(...)`; added `review_skipped_error`
  key to en/zh visualize.yaml.

Other PR changes applied as-is:
* `executors.py` / `cloud_provider.py`: inline Gemini 2.5/3.x default-down
* `loader.py`: section_map entry for `visualize`
* `init.py`: `capabilities.visualize` default with max_tokens=16384
* `code_generator_agent.py`: defensive root-tag trim for svg/html

Closes #489.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 17:50:56 +08:00
Truffle
69ea8b3c90 fix(auth): make require_auth async so the user ContextVar reaches the endpoint (#485)
Fixes #481. Makes `require_auth` and `require_admin` `async def` so the user ContextVar set inside the dep is visible to async endpoints; sync deps run via `anyio.to_thread.run_sync` under `copy_context()` and the set is discarded on return.
2026-05-28 17:43:23 +08:00
Bingxi Zhao (Frank)
932987921b support lemonade & minor fixes 2026-05-28 17:23:09 +08:00
Bingxi Zhao (Frank)
6c024857b7 release: v1.4.1 — security & stability patch
Security: lock down the TutorBot tool sandbox (shell exec is opt-in, all
filesystem/shell access confined to the bot workspace) and isolate per-user
resources, closing #518, #517, #516, #515, #514 and #506 (first hardened in
#507).

Bug fixes: chat input disabled after the first turn (#520), KB embedding
failure on long documents (#521 / #509), profile creation under Docker
(#512 / #513), Qwen reasoning models failing native tool calling (#527 / #528),
the GPT-5 init-wizard token parameter (#508), and oversized session-event
truncation (#524).

Features: HTTP/SSE API for multi-turn chat with a specific TutorBot (#511),
multimodal image fallback for vision-capable providers without a capability
entry, safe ZIP knowledge upload, and a /settings/network page with model
fetching (community PRs #522 and #523 reimplemented locally).

Also bumps __version__ to 1.4.1, adds the v1.4.1 release notes, updates the
README Releases section, and ships the Astro + Starlight docs site under site/.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
v1.4.1
2026-05-27 23:16:00 +08:00
wedone
b2f2002a0a fix(chat): enable native tool calling for reasoning models via OpenAI-compatible endpoints (#528)
* fix(chat): disable thinking mode for native tool calling and strip TOOL label when unavailable

* fix(chat): only disable thinking for reasoning models when native tool calling is active

Previous fix unconditionally set enable_thinking=False for all models
when use_native_tools=True. Now gate on has_thinking_tags() so only
reasoning models (e.g. Qwen3.6-Plus matched via "qwen" prefix) get
thinking disabled. Non-reasoning models are unaffected.

* fix: enable native tool_calls for reasoning models via custom OpenAI binding

Reasoning models (e.g. Qwen3.6-Plus) accessed through a generic OpenAI-compatible binding lacked the enable_thinking parameter that DashScope sets automatically. Without it the Bailian API defaults to thinking mode but the label protocol confuses the model into writing tool-call JSON inside content instead of using native tool_calls, causing tool_without_calls violations and infinite retries. Changes: Inject enable_thinking True for reasoning models whose binding lacks a thinking_style; Append a system-prompt note telling reasoning models to ignore the label protocol; Use implicit_think_label LABEL_FINISH for reasoning models with native tool calling.

* fix: escape quotes in reasoner protocol note strings

* fix(chat): fix Qwen 3.6 Plus tool call failures

- Move _is_reasoner assignment before first use to fix UnboundLocalError
- Add custom binding capabilities for OpenAI-compatible endpoints
- Enable supports_tools and has_thinking_tags for custom providers

Fixes tool call failures with reasoning models via OpenAI-compatible APIs

* fix(capabilities): change custom binding has_thinking_tags to False

Rely on MODEL_OVERRIDES for per-model detection (qwen/deepseek/qwq
prefixes) instead of hardcoding True for all custom endpoints.
Prevents enable_thinking injection and reasoner protocol notes from
being incorrectly applied to non-reasoning models like GPT-4o.
2026-05-27 20:22:22 +08:00
xiongjnu
c1932dcb0a feat: truncate oversized event payloads in session response (#524)
RAG tool results can return KB document content exceeding 1MB per event,
causing the frontend TraceSurface to run out of memory when loading large
sessions. Truncate tool_result and observation payloads at 1MB in the
get_session endpoint, marking truncated events with _truncated: true.

The LLM context builder reads from a separate content-only store and
is unaffected by this truncation.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 20:22:08 +08:00
washi4
5c0af9983a fix: prevent Document nodes from bypassing chunking pipeline (#509)
LlamaIndex's Document class inherits from BaseNode, so the previous
isinstance(doc, BaseNode) check classified all Documents as pre-embedded
nodes, skipping SentenceSplitter entirely. This sent full-document text
(1M+ chars) to the embedding API, triggering HTTP 400 input-length errors.

Replace the type check with an explicit embedding-presence check that
correctly distinguishes pre-embedded nodes (e.g. ImageNode from multimodal
loaders) from regular Documents that still require splitting.
2026-05-27 20:21:57 +08:00
Kagura
c90fae5609 fix(security): harden ExecTool defaults against command injection (#506) (#507)
* fix(security): harden ExecTool defaults against command injection (#506)

- Default restrict_to_workspace to True (was False), confining commands
  to the working directory unless explicitly opted out
- Add deny patterns for network exfiltration (curl, wget, nc, ssh, scp,
  rsync, ftp, socat)
- Add deny patterns for script interpreter exfiltration (python -c,
  perl -e, ruby -e)
- Add deny patterns for sensitive file access (/etc/passwd, /etc/shadow,
  /etc/sudoers) and privilege escalation (useradd, usermod, crontab,
  chmod world-writable)
- Add comprehensive test suite (32 tests) covering deny patterns,
  workspace restriction, and command execution

* fix(tests): use pytest.mark.asyncio for Python 3.14 compatibility

asyncio.get_event_loop() raises RuntimeError in Python 3.14 when
no event loop is running. Switch to pytest-asyncio's async test
decorator which is already a project dependency.
2026-05-27 20:21:48 +08:00
lezhimiffyliu
1218236004 Fix GPT-5 token limit parameter in init wizard probe (#508) 2026-05-27 20:21:33 +08:00
wedone
71e4396b92 fix(settings): add profile button when no profiles exist (#513)
When the LLM/Embedding/Search settings page has no profiles configured, the UI displayed 'No profiles configured. Add a profile to start.' but provided no button to actually add one. The add-profile button was only visible inside the profile editor, which never rendered when the list was empty - creating a dead end for new users.

Add a '+ Profile' button in the empty-state view, matching the existing button style used in the profile editor.

Closes #512, Closes #505
2026-05-27 20:21:24 +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>
v1.4.0
2026-05-22 21:09:22 +08:00
Bingxi Zhao (Frank)
81d081d968 update readme 2026-05-22 20:36:55 +08:00
Bingxi Zhao (Frank)
921b1d6cff update readme 2026-05-22 20:32:02 +08:00
Bingxi Zhao (Frank)
ca7916bc57 fix: docs, docker deployment & official web 2026-05-22 20:19:32 +08:00
Bingxi Zhao (Frank)
c9a833f7c3 update readme 2026-05-22 02:12:46 +08:00
Bingxi Zhao (Frank)
206b775ad4 fix: unblock v1.4.0-beta release — Docker build + CI test alignment
web/lib/api.ts: defer NEXT_PUBLIC_API_BASE placeholder check from
module-load to first call. Docker bakes the literal placeholder for
runtime sed substitution, but Next.js evaluates this module during
static export of every prerendered page — the old throw failed the
admin/users page export and aborted the entire build.

Test alignment with shipped code (no behavior change):
- test_path_service: override _workspace_root alongside _project_root,
  since get_memory_dir() reads workspace_root, not _user_data_dir.
- test_meta_settings: assertions now match shipped defaults
  (l2_budget=20, min_chunk_chars=1000, max_chunk_chars=64000).
- test_unified_ws_turn_runtime + test_regenerate: drop emit_calls
  assertions; turn_runtime doesn't emit a memory trace after chat
  turns (feature was never wired up).
- test_turn_runtime_subscribe: 200 polls × 10ms instead of 20 × 0,
  Python 3.14's asyncio scheduler doesn't give sleep(0) enough ticks
  for the subscriber-append race.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
v1.4.0-beta
2026-05-22 00:21:41 +08:00
Bingxi Zhao (Frank)
0af2e7e0e1 update pypi 2026-05-22 00:02:44 +08:00
Bingxi Zhao (Frank)
4a1543e3c1 ci: drop docs.yml workflow
VitePress GitHub Pages deploy is not in use; remove the workflow added
alongside the pypi-release fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 23:56:18 +08:00
Bingxi Zhao (Frank)
c4b96e74e5 ci: untrack .github from gitignore and add pypi-release/docs workflows
The .github entry in .gitignore silently excluded pypi-release.yml and
docs.yml from version control, so the PyPI publish workflow never reached
the default branch and didn't fire for release events.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 23:55:45 +08:00
Bingxi Zhao (Frank)
de08fde9e1 docs: update readme 2026-05-21 23:43:06 +08:00
Bingxi Zhao (Frank)
f8c76f4ff2 update logo 2026-05-21 21:32:13 +08:00
Bingxi Zhao (Frank)
a4bc7e0799 docs:add logo 2026-05-21 21:29:37 +08:00
Bingxi Zhao (Frank)
ff8b6a6d80 docs: figs&docker settings 2026-05-21 21:16:53 +08:00
Bingxi Zhao (Frank)
589327a49b docs(readme): drop %20 padding inside language pills, match ragflow spacing
Restores shields.io default internal padding on each pill and keeps
the single &nbsp; between pills. Height stays at 40 so the glyphs
read at the size we landed on.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 19:48:02 +08:00
Bingxi Zhao (Frank)
5059495ec4 chore(assets): compress dt-memgraph.png (2.3 MB → 446 KB)
Resize from 2940 px wide to 1600 px and palette-quantize to 256 colors,
keeping text/labels readable while bringing the file in line with the
other dt-*.png screenshots used in the README.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 19:40:38 +08:00
Bingxi Zhao (Frank)
17a72797cd docs(readme): bigger language pills, tighter gap, breathing room inside
- height 36 -> 40 so glyphs read clearly without a magnifier
- &nbsp;&nbsp; gap between pills -> single &nbsp; so the row stays
  compact
- one leading + trailing %20 space inside each badge label so the
  text doesn't kiss the pill edges

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 19:34:56 +08:00
Bingxi Zhao (Frank)
09d3743777 docs(readme): bump language-pill height to 36px for larger glyphs
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 19:29:57 +08:00
Bingxi Zhao (Frank)
d1c263fb71 docs(readme): add &nbsp; gaps between language pills
Inserts two non-breaking spaces between each language pill so the
row reads less cramped without forcing a wrap.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 19:20:54 +08:00
Bingxi Zhao (Frank)
cfa6cd419b docs(readme): scale language pills to height=28 for a chunkier hit area
Bumps the language-switcher SVGs to 28px tall so the pills line up
better with the Trendshift badge above and the Python / Next.js
shields below, and gives the labels a more readable text size on
high-DPI displays.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 19:18:00 +08:00
Bingxi Zhao (Frank)
4a483e07e6 docs(readme): rewrite Explore + Key Features for v1.4.0-beta, drop Roadmap section
- Rewrite Explore DeepTutor section around v1.4.0-beta surfaces:
  Chat (5 modes + Auto + new tools), Co-Writer (split editor),
  Book (GeoGebra viewer + fingerprints), Knowledge Bases (LlamaIndex,
  versioned indexes), Space (Chat History / Notebooks / Q-Bank / Skills),
  three-layer Memory (L1/L2/L3 + Memory Graph), unified Settings.
- Update Key Features to match: 5 chat modes, composable tools (ask_user,
  web_fetch, write_note, list_notebook, github_query), Space, three-layer
  Memory, unified Settings + UsageTracker.
- Swap removed figures (dt-knowledge.png, tb.png) for new ones
  (dt-kb.png, dt-memgraph.png, dt-settings.png, dt-space.png,
  dt-tutorbot.png); refresh dt-chat / dt-cowriter / dt-memory.
- Delete the static Roadmap section; add a pointer to issue #498
  near the welcome-PR note at the top so the roadmap stays open.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 19:10:40 +08:00
Bingxi Zhao (Frank)
b2aa9bfb4a docs(readme): fix Arabic/Hindi/Thai badge rendering, darken pill colors
shields.io uses Verdana/Helvetica fallbacks that lack proper text
shaping for Arabic (RTL join), Devanagari (combining marks), and
Thai (combining tone marks), so the native names rendered as
separated, broken glyphs. Switch those three to ASCII names
(Arabic / Hindi / Thai) to mirror ragflow's same workaround; the
links still resolve to the Arabic / Hindi / Thai README files.

Also bump pill colors from DBEDFA / DFE0E5 to BCDCF7 / CDCFD4 so
they read better against the page background.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 19:10:19 +08:00
Bingxi Zhao (Frank)
2bcc8bfff2 docs(readme): adopt ragflow-style pastel language pills
Drops the flat-square shields in favor of the lighter ragflow pattern:
an HTML <p align="center"> wrapper with <a><img> pills using DBEDFA
(soft blue) for the active English link and DFE0E5 (soft grey) for
the ten translations. The header now reads cleaner alongside the
existing Trendshift / Python / Next.js / License badges.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 19:05:06 +08:00
Bingxi Zhao (Frank)
7a36e87dbf docs(readme): switch language switcher to badge pills, place under trending
Replaces the flag-based language line at the bottom of the header
with shields.io badge pills positioned right under the Trendshift
badge. English is highlighted (blue), the ten translations use a
neutral grey. Same destinations as before.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 19:00:25 +08:00
Bingxi Zhao (Frank)
0ab5750eba docs(readme): note --pre install path for v1.4.0-beta
PyPI normalizes ``1.4.0-beta`` to ``1.4.0b0``, so the default
``pip install -U deeptutor`` stays on the latest stable. Add a short
callout under Option 1 covering ``pip install --pre`` and the exact
``deeptutor==1.4.0b0`` pin.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 18:22:15 +08:00
Bingxi Zhao (Frank)
2c1b8e56b2 release(1.4.0-beta): docs, version bump, CLI init wizard, packaging
- __version__.py bumped to 1.4.0-beta; pyproject.toml adds the
  ``deeptutor`` package-data globs so prompt YAMLs / capability
  prompts / Markdown templates ship in the PyPI wheel.
- New assets/releases/ver1-4-0-beta.md covers Auto Mode, Memory v2,
  agentic-engine rewrite, chat + LlamaIndex RAG refactor, new chat
  tools, Visualize+Animator merge, settings split, capabilities
  unification, multi-user / Zulip fixes, env/launcher rewrite.
- README.md adds the v1.4.0-beta entry at the top of the release
  notes; v1.3.0 rolls into the collapsed past-releases block.
- deeptutor_cli gains init_wizard.py (interactive provider menu,
  env-var auto-detect, live model-list fetch with curated fallback,
  optional connectivity probe) and a shared _tool_result helper;
  chat / common / config_cmd / init_cmd / provider_cmd updated to
  match.
- Removed legacy scripts/ helpers (_cli_kit, audit_prompts,
  check_install, generate_roster, migrate_kb, migrate_user_data,
  sync_prompts_from_en, test_embedding, test_llm_api) -- replaced by
  CLI subcommands or no longer relevant.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 18:08:50 +08:00
Bingxi Zhao (Frank)
90a2c14c81 chore: backend + frontend follow-ons for v1.4.0-beta
Wires the new memory / capability / settings / quiz subsystems into
existing surfaces and finishes the chat-pipeline follow-on work.

Backend:
- Session services pick up the cumulative source inventory + new tool
  tags (turn_runtime, sqlite_store, pocketbase_store, protocol,
  base_session_manager).
- LlamaIndex RAG pipeline config / document_loader / retrievers
  tightened; rag/service.py routed to match.
- Sessions / unified_ws / settings / notebook routers updated for
  delete-chat-turn, multi-user, and the new tool surface.
- TutorBot manager + Zulip channel + openai_compat_provider follow-on
  fixes layered on top of the v1.3.10 SSL/Zulip sweeps.
- runtime/{banner, launcher, orchestrator}, services/setup/init,
  prompt/manager, json_parser refined for the runtime-settings
  rewrite.

Frontend:
- Co-Learn pages and session-surfaces removed (folded into chat).
- Chat composer / messages / trace / session panels, sidebars,
  common modals, markdown renderers, and i18n updated for the new
  ask_user / write_note / source-inventory flow.
- Admin, agents, co-writer, playground, book pages picked up the
  shared updates.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 18:08:22 +08:00
Bingxi Zhao (Frank)
4df05d02da feat(quiz/book): quiz follow-up chat composer, GeoGebra viewer, book updates
Quiz follow-up:
- New FollowupChatComposer + QuizFollowupContext let the user start a
  chat thread directly from a quiz question. The composer reuses the
  main ChatComposer (look, @space pickers, KB picker, attachments,
  LLM selector) but routes sends through a dedicated follow-up
  controller.
- New quiz_judge router + quiz-judge.ts helper power judging
  follow-up answers inline.
- The older QuestionFollowupPanel.tsx is removed; QuizConfigPanel /
  QuizViewer are updated to the new follow-up surface.

GeoGebra viewer:
- New Geogebra.tsx applet renderer (loaded via the official GGB
  applet script) so geometry / algebra snippets can open inline
  alongside chat answers. GeogebraOpenCTA + GeogebraTabContext add
  the tab plumbing.

Book updates:
- book/blocks/quiz.py + book/engine.py + storage.py and the related
  book components pick up the new quiz surface.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 18:07:39 +08:00
Bingxi Zhao (Frank)
acd0d9329d feat(capabilities): unify infra, merge Animator into Visualize, split settings UI
Capability infrastructure:
- New capabilities/_shared.emit_capability_result helper fills the
  result envelope (label, summary, payload, render hints, UsageTracker
  totals) consistently across modes.
- StatusI18n loads capability status copy from
  capabilities/prompts/{en,zh}/<name>.yaml; legacy main.yaml strings
  removed.
- New capabilities_settings router + service-config module power the
  /settings/capabilities admin page (live capability list, defaults,
  per-capability overrides).

Visualize + Animator merge:
- Visualize's AnalysisAgent now picks one of six render_types:
  svg / chartjs / mermaid / html (text pipeline) or manim_video /
  manim_image (Manim subprocess). The result envelope carries
  render_type so the frontend delegates to the right viewer.
- math_animator capability is folded behind Visualize; the standalone
  MathAnimatorConfigPanel.tsx is removed. The Animator sidebar entry
  is gone, but Manim outputs and existing records remain unaffected.

Settings UI:
- /settings page split into appearance / capabilities / embedding /
  llm / mcp / memory / search / status / tools tabs with a shared
  layout and items index.
- New /settings/tools page lists chat-mountable tools and surfaces
  availability (e.g. gh for github_query) via a new tools router.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 18:06:14 +08:00
Bingxi Zhao (Frank)
7bdb10b700 feat(chat): Auto mode router + new chat tools (ask_user, web_fetch, etc.)
Auto capability (agents/auto/) gains a three-stage agent loop:
ANALYZING (one LLM call, streamed as thinking) -> DELEGATING (router
emits delegate_to_<cap> tool calls or atomic tool calls, with bounded
retries and a same-cap quota) -> SYNTHESIZING (final inline answer).
Sub-capability events flow through forward_events with call_id tagging
so conversation history keeps only Auto's own synthesis.

New chat-mountable tools:
- ask_user: pauses the turn for 1-3 structured questions, frontend
  renders a card the user navigates and submits in one batch
- web_fetch: HTTP + readable-content extraction with strict
  scheme/private-IP/size guards (pre-flight + post-redirect)
- write_note: replaces save_to_notebook; append (new record) and
  edit (existing record by id) modes
- list_notebook: read-only index / drill-down listing; only mounted
  when the user has notebooks
- github_query: read-only ``gh`` CLI wrapper (pr/issue/run/repo plus
  GET-only api); no mutation verbs reachable

Updates chat agentic_pipeline.py + agentic_chat.yaml (en/zh) to the
new tool surface and source-inventory contract, refits
tools/builtin/__init__.py as the single place to register
chat-mounted tools and their argument-augmentation wrappers, and
tightens core stream + tool_protocol around tool-result metadata.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 18:05:15 +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)
2b7242081f feat(memory): three-layer memory subsystem (L1/L2/L3) with workbench
Replaces the flat single-blob memory page with a structured store:
- L1 captures raw run traces; L2 holds normalized document records;
  L3 holds curated slots per surface (chat, notebook, book, TutorBot).
- New consolidator pipeline (chunker, guards, parse, references, runs,
  modes, line-doc, meta) turns traces into versioned line-oriented
  documents with stable ids and snapshot history.
- Per-user isolation flows through PathService; the store API is
  stateless.

UI ships a dedicated /memory workbench with graph / L1 / L2 / L3 /
resolve subpages, plus a reusable MemorySection embedded where the
legacy panel lived.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 18:02:32 +08:00
Sam
6c2615df39 fix(visualize): unblock Gemini 2.5+, harden Visualize pipeline
Six bugs that combined to break the Visualize capability on Gemini 2.5
Flash (and similar thinking-by-default models). Each is independently
useful, but the user-visible symptom — Visualize "kind of works but
output is randomly truncated at ~370 chars" — needs all of them.

1. Gemini 2.5/3.x reasoning-tokens default (root cause)

   Gemini 2.5+ models burn most of `max_tokens` on internal "thinking"
   tokens by default. With `max_tokens=4096`, ~3900 went to reasoning
   and only ~160 came out as actual content, causing finish_reason=length
   on every multi-step pipeline (Visualize codegen + review, Deep Solve,
   anything that asks for a structured output beyond a sentence).

   Default `reasoning_effort="none"` for Gemini 2.5/3.x models when the
   caller doesn't specify, in all three execution paths:
   - provider_core/openai_compat_provider.py:_build_kwargs (live path)
   - executors.py:sdk_complete / sdk_stream (legacy SDK path)
   - cloud_provider.py:_openai_complete / _openai_stream (aiohttp fallback)

2. visualize capability had no agents.yaml entry

   `get_agent_params("visualize")` silently fell through to the 4096
   default because there was no section_map entry and no
   DEFAULT_AGENTS_SETTINGS entry. Added both, with a 16384-token budget
   appropriate for full HTML pages.

3. Review stage crashed hard on JSON parse failure

   `ReviewAgent.process` does `ReviewResult.model_validate(extract_json_object(response))`.
   When the model returned prose instead of JSON (common with large SVGs
   that the model can't escape into a JSON string), the parse raised and
   killed the entire turn. Wrapped pipeline.run_review() in try/except
   so review failure falls back to the unreviewed draft and the user
   still gets a rendered result.

4. Codegen output not trimmed to the root tag

   Models often wrap SVG/HTML in prose ("Here you go: <svg>…</svg>
   Enjoy!") or emit a closing code fence on the same line as `</html>`,
   which `extract_code_block`'s regex (requiring a leading \n before
   the fence) doesn't strip. Added defensive root-tag trimming for
   render_type=="svg" and render_type=="html".

Verified end-to-end on Gemini 2.5 Flash via the CLI and headless
Playwright: full 22 KB long-division HTML page, no truncation, all
interactive elements present, multi-step walkthrough completes
correctly (7852 ÷ 6 → 1308 R 4).
2026-05-17 16:36:05 +09:00
Bingxi Zhao
cade7897f4 Merge pull request #480 from wedone/fix/zulip-upload-and-send
fix(zulip): 修复 Zulip 通道附件上传与消息发送的 BUG,支持 Bot 自动订阅频道
2026-05-15 00:12:08 +08:00
Bingxi Zhao
3a2f169063 Merge pull request #478 from mtsui-cmyk/fix/quiz-textarea-vertical-resize
fix: allow quiz answer textarea vertical resize
2026-05-15 00:11:44 +08:00
WeDone
e8f14054b5 fix(zulip): 优化已订阅频道时的日志级别避免误导性WARNING
问题:Bot已订阅所有频道时,add_subscriptions仍返回
      non-success结果,原代码记录WARNING级别日志造成误导。

修改:
- 根据already_subscribed计算实际订阅情况
- 有新增订阅时记录INFO,无新增时记录INFO提示已订阅
- 非success但全部已订阅时降级为DEBUG日志
- 真正失败时才保持WARNING级别
2026-05-14 16:25:16 +08:00
WeDone
ac06a05e22 fix(zulip): 支持所有mention flags类型修复频道@mention无响应问题
问题:在Zulip频道中@机器人没有反应,私聊正常。
根因:_is_mentioned方法只检查mentioned flag,遗漏了
      wildcard_mentioned、stream_wildcard_mentioned、
      topic_wildcard_mentioned等通配符mention标志。

修改:
- _is_mentioned支持所有四种mention flags
- 增强日志输出便于排查问题
- 补充边界测试用例(flags缺失、非字符串元素等)
2026-05-14 11:37:06 +08:00
iwedo
9f6ebe91ba feat(zulip): 支持Bot自动订阅频道以接收话题中的@mention消息
问题:在Zulip话题中@机器人没有反应,deeptutor容器无日志。
根因:Bot未订阅频道,Zulip服务器不会推送频道消息事件给未订阅的Bot。

主要修改:
- ZulipConfig新增subscribe_streams配置项,支持指定频道名或通配符'*'
- start()中新增_subscribe_to_streams()自动订阅频道
- _subscribe_to_streams()支持异常保护,订阅失败不阻断Bot启动
- 通配符'*'与显式频道名混合使用时合并处理
- _on_message()添加调试日志便于排查
- _bot_full_name属性用于后续@mention内容匹配

测试修复:
- TestDownloadAttachments添加get_media_dir mock解决yaml导入错误
- TestUploadAndSend改用call_args_list筛选上传调用修复KeyError
- 新增TestSubscribeStreams测试类(7个用例)
- 将test_stop_cancels_typing_tasks移至TestStop类
2026-05-14 10:29:44 +08:00
WeDone
33aeab41a3 test(zulip): 添加附件上传与发送修复的单元测试
修复现有 test_upload_uses_call_endpoint 测试(使用临时文件替代不存在的路径),新增测试覆盖:- _resolve_media_path: 本地路径直返、Zulip 路径缓存查找、Zulip 路径下载、完整 URL 解析、无效路径返回 None- _upload_and_send: 传递文件对象而非字符串、无法解析路径时跳过- send 元数据补全: 从 _recipient_map 补全缺失路由信息、已有元数据不被覆盖- send _tool_hint 过滤: tool_hint 消息被跳过、普通 progress 消息正常发送
2026-05-14 10:29:44 +08:00