The chat capability silently dropped `extra_headers` from the active
LLM profile because three downstream call sites in `AgenticChatPipeline`
did not forward them:
- `_build_openai_client()` constructed `AsyncOpenAI` /
`AsyncAzureOpenAI` without `default_headers`, so custom headers
required by some gateways (e.g. a `User-Agent` override to bypass
WAF allowlists that block `OpenAI/Python <ver>`) were lost on the
native-tool-calling path.
- `_stream_messages` and `_run_react_fallback` invoked `llm_stream()`
with `model`, `api_key`, `base_url`, `binding` but no
`extra_headers`. The factory's `_resolve_call_config` treats this
set of caller-provided fields as an explicit override and rebuilds
`LLMConfig` with empty `extra_headers`, bypassing the catalog value
loaded by `get_llm_config()`.
Pulls `extra_headers` from `llm_config` once in `__init__` and
forwards it from all three call sites.
Reproduce: configure an OpenAI-compatible gateway whose WAF rejects
the default `OpenAI/Python <ver>` User-Agent; set
`extra_headers: { "User-Agent": "Mozilla/5.0 ..." }` on the active
LLM profile in `model_catalog.json`. Before this change, chat returns
HTTP 403 "Your request was blocked." After, the override reaches the
gateway and chat succeeds.
- Swap reasoning_content/reasoning fallback order in _parse() to match
the precedence used when extracting reasoning_content (per Copilot review)
- Add reasoning_content → content fallback in _parse_chunks() for both
provider_core and tutorbot providers
- Fix streaming path in factory.py: when only reasoning chunks are
emitted (no direct content), fall back to response.content so
downstream consumers receive non-empty responses
- Harden idea_agent against non-dict JSON payloads
DeepSeek models (v4-flash, reasoner, etc.) return the actual response in the
reasoning_content field while leaving content empty when thinking mode is
enabled. The _parse() method only fell back to m.reasoning (DashScope-style),
causing "LLM returned empty response" errors.
Also fix idea_agent to handle LLM responses that are JSON arrays instead of
objects with an "ideas" key.
Embedding endpoint URLs are now transparent end-to-end: Settings shows the
exact URL DeepTutor will POST to, legacy `/v1`-style bases are migrated to
full `/embeddings` / `/api/embed` URLs, the embedding client rejects
known-provider misconfigurations early, and OpenRouter routes through the
same exact-URL HTTP adapter as other providers.
LlamaIndex RAG now refreshes embedding state before initialize/search/add,
validates persisted vectors before retrieval, and reports invalid indexes
with `needs_reindex: true` instead of raw NumPy/`NoneType` errors.
Memory refresh strips `<think>` / `<thinking>` blocks from reasoning-model
output before writing PROFILE.md / SUMMARY.md, and existing memory files
self-repair on read.
Also fixes a Deep Solve runtime regression where `MainSolver` still passed
a stale `attachments` keyword to `SolverAgent.process()`.
Adds release notes (assets/releases/ver1-3-2.md) and updates README.
Made-with: Cursor
Stability release after v1.3.0 covering safer RAG/KB routing, stronger
embedding validation, more reliable Docker/TutorBot restarts, Web UX
fixes, and Windows/encoding hardening. See assets/releases/ver1-3-1.md
for the full notes.
Made-with: Cursor
Rebased onto dev (post-#348) and resolved two UI conflicts (`web/app/(workspace)/chat/[[...sessionId]]/page.tsx` drops the now-dead `replaySnapshot` helper; `web/components/chat/home/ChatMessages.tsx` switches the last-assistant action button from the old `RotateCcw`/Retry to `RefreshCcw`/Regenerate). Smoke tests green (199 passed) and all required checks pass.
Merging: adds a `regenerate` capability wired through CLI (`/regenerate` · `/retry`), WebSocket (`type: "regenerate"`), and Web UI (per-message Regenerate button). Backend rolls back the trailing assistant via `SQLiteSessionStore.delete_message`, reuses `start_turn` through `_persist_user_message=False` / `_regenerate=True`, skips `memory_service.refresh_from_turn` on regeneration, and surfaces non-fatal `regenerate_busy` / `nothing_to_regenerate` errors. Also includes empty-response diagnostics in `_stage_responding`. 18 new tests.
Rebased onto latest dev (post-#352) to pull in the lazy loguru import in `deeptutor/tutorbot/channels/manager.py`, which was the root cause of the smoke-test failures (unrelated to this PR's own diff).
Merging: adds per-stage `max_tokens` and `temperature` knobs under `capabilities.chat` in `agents.yaml`, bumps the `responding`/`answer_now` defaults from 1800 → 8000 to fix mid-sentence truncation on long answers, and keeps safe fallbacks in `_ChatLimits.from_config` for legacy configs. 10 new unit tests covering loader resolution and dataclass coercion.
Resolved conflicts in:
- deeptutor/agents/notebook/summarize_agent.py
Kept the YAML-driven record_hints lookup from dev (covers chat,
co_writer, guided_learning, default), instead of the inline
dict from guide2.0 which only had chat + co_writer.
- deeptutor/capabilities/visualize.py
Kept dev's load_answer_now_prompts(...) path so the answer-now
fast path stays prompt-externalised under
deeptutor/agents/visualize/prompts/{en,zh}/answer_now.yaml.
- deeptutor/services/prompt/manager.py
Merged the MODULES list: dropped 'guide' (deleted by guide2.0),
added 'book' from guide2.0, and kept dev's 'notebook',
'visualize', 'chat' modules.
Made-with: Cursor
- Move inline LLM prompts out of capabilities/agents into versioned
prompt YAMLs under each agent's prompts/{en,zh}/:
- notebook: analysis_agent, summarize_agent
- question/research/solve/visualize: answer_now
- Slim down capability modules (_answer_now, deep_question,
deep_research, deep_solve, visualize) to load prompts via the
prompt manager instead of hard-coding strings
- Update services/prompt/manager.py to support the new prompt paths
- Refresh web config panels (quiz, research, visualize, math-animator)
and shared types to align with the new capability options
- Update Mermaid, ChatMessages, TracePanels and settings page,
plus en/zh locales for the new copy
Made-with: Cursor
* 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
Each capability now owns its own answer-now branch so the early-exit
respects the capability's natural output shape:
- chat -> synthesize markdown answer (existing behavior)
- deep_solve -> skip planning + reasoning, jump to writer
- deep_question -> skip ideation, emit full quiz JSON in one structured call
- deep_research -> skip rephrase/decompose/research, write report directly
- math_animator -> skip analysis/design/summary, KEEP code-gen + render
- visualize -> skip analysis/review, emit renderable code in one call
The orchestrator no longer rewrites answer_now turns into chat. It now
preserves active_capability and only falls back to chat when the
originally selected capability is missing from the registry.
Shared plumbing lives in deeptutor/capabilities/_answer_now.py
(extract gate, trace summary formatter, skip notice, LLM stream
wrapper, chunk joiner). Each fast-path preserves the same result
envelope so QuizViewer / MathAnimatorViewer / VisualizationViewer
render unchanged, and prepends a "Skipped X stage(s)" notice so the
user knows it was a best-effort early exit.
Frontend: handleAnswerNow no longer overrides snapshot.capability.
Tests: rewrote the orchestrator routing tests for the new contract;
added tests/capabilities/test_answer_now.py with 28 cases covering
the helpers and every per-capability fast-path (including unparseable
JSON / invalid render_type / fence-wrapped JSON recovery, and a
math_animator test that verifies analysis/design/summary are NOT
invoked while code-gen + render ARE).
Updated v1.1.1 release notes to reflect the new design.
Made-with: Cursor
This PR fixes two related issues:
1. Qwen vLLM 'System message must be at the beginning' error:
- deeptutor/agents/chat/agentic_pipeline.py: Merge system_prompt and memory_context into single system message, filter out system messages from conversation_history
- deeptutor/services/session/context_builder.py: Filter out system messages from DB since summary is already added as system
- deeptutor/agents/chat/chat_agent.py: Merge system prompt and RAG context into single system message
2. History reference (@reference) empty context issue:
- deeptutor/services/session/turn_runtime.py: Add fallback to raw record content when NotebookAnalysisAgent.analyze() returns empty string
Benefits:
- Fixes Qwen vLLM compatibility issue completely
- Enables history reference feature to work correctly
- Reduces token usage by eliminating duplicate system messages
- Does not break any functionality - system context from DB is already in compressed_summary
- Cleaner message structure with exactly one system message at position 0
Testing:
- Verified with Qwen model via vLLM - no more template errors
- Chat with memory files (PROFILE.md/SUMMARY.md) works correctly
- Chat with conversation history works correctly
- History reference (@reference) now works correctly
- Conversation continuation works without errors
- No regression with other models (GPT-4, etc.)
Closes#294
Fixes semantic overloading introduced by PR #281 — history_context (conversation
history) is no longer mixed with the generated-questions dedup list.
- Add dedicated `previous_questions` parameter through Generator pipeline
- Extract `_strip_template_knowledge_context()` reused by both generate and repair paths
- Add `_format_previous_questions()` with MAX_PREVIOUS_QUESTIONS=20 cap
- Move language labels into YAML templates (en/zh) to avoid language mixing
- Simplify coordinator to pass raw list instead of string concatenation
Made-with: Cursor
Replace asyncio.create_subprocess_exec with subprocess.Popen + reader
threads + asyncio.Queue. This fixes Windows SelectorEventLoop
incompatibility while preserving real-time line-by-line progress output
(unlike subprocess.run which buffers until completion).
Made-with: Cursor
- Replace litellm with native openai + anthropic SDKs across both
services and tutorbot layers
- Add 5 new providers: mistral, stepfun, xiaomi_mimo, qianfan, ovms
- Add `backend` field to ProviderSpec for SDK routing
- New TutorBot OpenAICompatProvider (openai SDK) and AnthropicProvider
(anthropic SDK), replacing LiteLLMProvider
- Rewrite services/llm/executors.py to use openai SDK directly
- Remove litellm from factory.py routing, token_tracker, provider_cmd
- Auto-fallback to streaming for tool-call format errors (fixes#265)
- Settings UI: provider dropdown with auto base-url fill
- Clean up litellm from requirements/cli.txt and pyproject.toml
Made-with: Cursor
The original implementation converted `fallback=None` to `{}`,
making `if data is None:` checks dead code in data_structures,
note_agent and reporting_agent. Use a `_UNSET` sentinel so callers
can explicitly request `None` as the failure value.
Also simplify control flow in data_structures and reporting_agent
to avoid raising ValueError inside bare try/except that wouldn't
catch it.
Made-with: Cursor
Instead of replacing asyncio.create_subprocess_exec with subprocess.run
(which loses real-time streaming and cancellation), fix the root cause:
set WindowsProactorEventLoopPolicy before uvicorn starts so that
create_subprocess_exec works correctly on Windows.
This preserves the original async streaming renderer while fixing
Windows compatibility at the event loop level.
Made-with: Cursor
This PR fixes multiple Windows compatibility issues that prevented
the Math Animator from generating videos on Windows systems.
### Changes
1. **renderer.py**: Fix subprocess execution on Windows
- Replace `asyncio.create_subprocess_exec` with `subprocess.run` + `asyncio.to_thread`
- The original approach silently fails on Windows when uvicorn uses SelectorEventLoop (default)
- New approach works regardless of event loop type
2. **code_generator_agent.yaml (en/zh)**: Add Manim v0.20.1 compatibility constraints
- Prohibit `MarkupText` (requires LaTeX)
- Prohibit `stroke_dash_pattern` parameter (not supported in v0.20.1)
- Prohibit `save_state()` method (not supported in MovingCameraScene)
- Applied to both `generate_system` and `retry_system` sections
3. **ChatComposer.tsx**: Suppress hydration warning for i18n placeholder
- Add `suppressHydrationWarning` to textarea
- Resolves SSR/CSR text mismatch warning for language-specific placeholders
### Testing
- ✅ CLI mode: Successfully generated Pythagorean theorem animation (660KB)
- ✅ Web mode: Successfully generated cone cross-section animation
- ✅ Auto-retry: First attempt error → LLM repair → second attempt success
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>