When the Responses API path is selected for newer OpenAI models
(gpt-5.x, o1, o3, o4) and an extra kwarg of `max_completion_tokens`
flows in (typically from `get_token_limit_kwargs(model, n)`), the
OpenAI SDK raises `TypeError` from `responses.create()` before any
HTTP request leaves the client.
`_should_fallback_from_responses_error()` only catches HTTP errors
that carry a `status_code`, so the call is never retried via Chat
Completions; the user just sees a stack trace. The bug exists on
both OpenAICompatProvider and AzureOpenAIProvider, in the chat and
chat_stream paths (4 sites total).
Add `adapt_chat_kwargs_to_responses()` that translates the alias to
`max_output_tokens` and is used at all four merge sites. The helper:
- preserves the existing `None`-drop semantics of the previous
dict-comprehension merge,
- only applies the alias when `max_output_tokens` is not explicitly
set by the caller,
- does not mutate the input.
Closes#437.
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.
The Provider <select> in Settings used `bg-transparent`, leaving the
native dropdown popover unpainted. On Edge/Chromium with the
`.dark` theme the popover renders against a white surface despite
`color-scheme: dark` being set, leaving option text near-invisible
(reported in #433 with screenshots).
Switch the shared `selectClass` to `bg-[var(--background)]` so the
closed select keeps its current visual (--background matches the
form panel in every theme) and the opened popover inherits the
themed surface — `#1a1918` in dark, `#faf9f6` in light, equivalent
in theme-snow / theme-glass.
Closes#433.
get_llm_config() prefers the resolver path over .env, so the env var
was silently ignored. Apply it as an override regardless of which path
produced the config.
Replace fragile json.loads() with parse_json_response() in code,
flash_cards, timeline, and deep_dive generators. Handles LLM
responses with markdown fences, preamble text, and malformed JSON.
DeepSeek only supports high/max for reasoning_effort; minimal is a
DeepTutor convention that maps to thinking.type=disabled. Update comments
to be accurate for each provider.
- Read LLM_REASONING_EFFORT from environment in config.py
- Pass config.reasoning_effort to chat_with_retry/chat_stream_with_retry
in both complete() and stream() (was previously dropped)
- Set to "low"/"medium"/"high" to enable thinking, leave empty to use
automatic detection based on reasoning_model_patterns
- 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.
Register Gemini as a first-class embedding provider with endpoint/env defaults, expose it in start_tour embedding selection, and add regression coverage for runtime resolution and wizard options
When TutorBot is connected to IM channels (e.g. Feishu, WeChat),
users can send images and other multimedia messages. These messages
are stored with content as an array of content-part objects rather
than a plain string. The frontend assumes content is always a string,
causing React Error #31 (Objects are not valid as a React child)
and rendering the chat page unusable.
Changes:
- Add normalizeMessageContent() utility to safely convert array/object
content to displayable strings
- Fix BotChatPage history parsing to handle non-string content
- Fix UnifiedChatContext hydrateMessages for non-string content
- Fix last_message display with truncation and type safety in
SessionList and HistorySessionPicker
- Normalize content to string and strip reasoning_content in backend
get_bot_history and get_recent_active_bots
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
- Add nvidia_nim provider to the registry (is_gateway, detect_by_key_prefix=nvapi-,
detect_by_base_keyword=api.nvidia.com, default_api_base=https://integrate.api.nvidia.com/v1)
- Add supports_stream_options field to ProviderSpec (defaults True, preserves existing
provider behavior)
- Set supports_stream_options=False for nvidia_nim — NVIDIA NIM silently hangs when
stream_options={"include_usage": True} is sent, so we omit it for this provider
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When the persisted ``status`` in ``kb_config.json`` is still a "live"
sentinel (``processing`` / ``initializing``) but a flat ``version-N``
directory on disk is already ready, ``get_info()`` previously returned
``status="processing"`` because the elif chain had no branch to recover
the case. The UI therefore showed a perpetual "Processing…" banner even
though the KB was fully usable.
This typically happens when the progress writer or worker process
crashes after the LlamaIndex version is finalised but before
``update_kb_status(name, "ready")`` rewrites kb_config.json — the
on-disk truth and the persisted status diverge.
Fix: in ``get_info``, after the existing ``effective_needs_reindex``
short-circuit, add a branch that promotes status to ``"ready"`` when:
- status is currently ``processing`` or ``initializing``,
- a ready ``version-N`` exists (``has_ready_llamaindex``),
- and the persisted progress stage is not ``error``.
The ``error`` guard preserves visibility of genuine indexing failures
when an older ready version still exists. The promotion clears the
stale progress banner to match the existing semantic in
``update_kb_status`` (where ready KBs drop progress).
The persistent ``kb_config.json`` is left untouched on read; the next
legitimate ``update_kb_status`` call cleans it up.
7 new tests in ``tests/knowledge/test_manager_get_info_status.py``
cover the headline #418 reproduction, the completed-stage variant, the
``initializing`` variant, and the negative cases (error stage, no ready
version yet, ready-status pass-through, mismatched-signature ->
needs_reindex precedence).
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
Two independent issues that block `python scripts/start_web.py` after a
clean install on Windows:
1. UnicodeDecodeError when streaming subprocess output
`_spawn()` opened the backend / frontend stdout pipe with `text=True`
but no explicit encoding. On Windows this defaults to the system
ANSI codepage (e.g. `gbk` on Chinese Windows), which raises
`UnicodeDecodeError` as soon as the child process emits a UTF-8 byte.
Fix: pin `encoding="utf-8"` and `errors="replace"` so any locale
produces clean, lossless output.
2. Missing runtime dependencies in requirements/server.txt
`deeptutor/services/llm/provider_core/__init__.py` unconditionally
imports `AnthropicProvider`, `OpenAICompatProvider`, and
`OpenAIResponses`, which in turn import:
- `loguru` (provider_core/base.py, openai_codex_provider.py,
openai_responses/parsing.py)
- `json_repair` (anthropic_provider.py, openai_compat_provider.py,
openai_responses/parsing.py)
These are declared only in `requirements/tutorbot.txt`, so
`pip install -r requirements/server.txt && pip install -e .` followed
by `python scripts/start_web.py` crashes with `ModuleNotFoundError`
before the API server can serve a single request.
Fix: declare both packages in `server.txt` with the same version
bounds used by `tutorbot.txt`.
Reproduced and verified on Windows 11 + Python 3.12 + a fresh venv.