* fix(book): retry an interactive page with thinking off when it runs out of room
deepseek-flash thinks by default and can spend the whole 16000-token
visualize budget on reasoning, so a book interactive block came back with
no code. When the page is empty or cut off before </html>, ask once more
with thinking turned off (thinking_off_effort_for) before failing. If that
still runs out of room, the error names the budget sent to the model and
the settings that change it.
The shipped default stays at 16000: the budget is shared by every visualize
caller, and 32768 breaks models with a lower output cap (#3018).
Refs #3011
* fix(llm): raise the visualize budget to 32k and cap each request to the model
A thinking model can spend 16k tokens before it writes any code, so the
visualize default is now 32768. Sent unchanged that would be rejected by
models whose output stops lower (gpt-4o and gpt-4o-mini at 16384) and could
overflow a small local context window, so every request now carries
min(budget, the model's known output limit, half the configured context
window). The cap lives in get_token_limit_kwargs, so it applies to every
caller; BaseAgent and the agentic loop pass the configured window.
deepseek-flash thinks by default and spent the whole 16000-token visualize
budget on reasoning, so book interactive blocks came back with no code.
Raise the default to 32768 and make the book's interactive errors name the
two settings that fix it: Max tokens under Settings -> Capabilities ->
Visualize, or turning off thinking for the model.
The first visit stored the detected palette and never listened for
prefers-color-scheme changes, so the theme stopped tracking the OS and
Settings had no System choice.
Do not write that fallback. Subscribe while the preference is missing or
"system", and add a System option in Appearance. New accounts default to
system so Apply does not freeze the snow palette.
`video_lesson` (CLI alias `lesson`) turns a question into a playable
Remotion explainer:
1. code_generation: the lesson writer drafts Lesson.tsx
2. render_check: compile and frame-check it, feeding failures back,
up to three attempts
3. render_output: write the player page and emit it as an html artifact,
along with the lesson's summary and source
npm packages are installed on first use while the first LLM call is
still running. The capability reports itself unavailable when node or
npm is missing. Its LLM budget lives under plugins.video_lesson in
agents.yaml (48k tokens by default: a whole lesson comes back in one
reply).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Empty LlamaIndex KBs and UID-mismatched volumes were reported as
"not initialized". Fail-fast on unwritable data dirs and remap the
non-root deeptutor user instead of swallowing chown failures.
Co-authored-by: Cursor <cursoragent@cursor.com>
Twenty-two community pull requests and the reports behind them. Where
v1.6.7 chased a token budget spent on hidden thinking, this one answers
a different complaint: I did a thing and the app quietly did nothing.
New surfaces: a recycle bin that makes a deleted chat recoverable,
search across the full text of your conversation history, and
`knowledge_frontier` — a tool that reads a knowledge base and goes
looking for what is not in it.
Fixes worth naming: a reasoning model that stops mid-thought now fails
with the counters that prove it rather than an opaque error; deep book
URLs open the book instead of the library; the reading outline tracks
the page again; an EPUB that macOS re-zipped reads as the book it is; a
file whose extraction produced nothing is listed with the reason instead
of skipped in silence; the launcher stops killing a backend that is
merely still starting.
Also in this commit: README prose plus all eleven translations, the
v1.6.8 release notes with v1.6.5 archived past the one-week line, three
duplicate keys removed from the locale files (`Delete permanently` had
two different zh values, and the wrong one was winning), and the mypy
annotation that made every `conn.execute` in the new file library look
like a call on None.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(config): bump probe budget for reasoning models
Reasoning models (o1/o3, gpt-5.x) require max_completion_tokens, and
the API rejects the test-connection probe when the completion budget
is too low to cover the internal reasoning pass. Bumps the default
probe budget to 4096 for models that use max_completion_tokens.
* fix(config): preserve probe token overrides
* review: seed the probe knob, and test the thing this PR changes
The raised fallback is unreachable. `get_agent_params` always returns both
keys — it falls back to `DEFAULT_AGENTS_SETTINGS`, then to a generic
0.5/4096 — so `_test_llm`'s constant never decides anything and the probe has
been running at 4096 all along. This PR, as written, changes nothing for
anyone.
What does change it is the seed, which had no `diagnostics` section at all: a
fresh agents.yaml never showed the knob, and a stale one kept whatever it
already said. Seeded at the same number the fallback names, because two lists
of the same value is how a default and its seed drift apart (#1316). The
temperature moves 0.5 -> 0.1 as a result, which is what `test_runner` always
meant to ask for: a diagnostic wants a reproducible answer.
`tests/config/test_reasoning_probe_budget.py` tested
`uses_max_completion_tokens()`, a function this PR does not touch. It now
pins the floor, that agents.yaml still wins over it, that an unusable value
falls back rather than raising, and that the seed and the floor agree.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: XZH <cto@xzh.ai>
Co-authored-by: Bingxi Zhao (Frank) <13051345080@163.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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.
A capability that makes several different LLM calls cannot be described
by one max_tokens: the step emitting a whole JSON plan and the step
writing one paragraph need different room. `chat` has said so since it
grew `exploring`/`responding`. `question` and `research` said the same
thing in module constants instead, where no user could reach them.
The cost of that was not theoretical. `capabilities.question.max_tokens`
governed exactly one of question's six LLM calls — the follow-up agent —
while the pipeline's five steps used constants that ignored it. The plan
step's constant sat below the capability's own ceiling, which is how
#1318 shipped a step that could spend its whole allowance thinking and
emit zero templates without an error. `EXPLORE_FINISH_MAX_TOKENS` had
been dead since it was written.
Generalises the seam that already worked rather than adding a parallel
one: `get_chat_params` becomes `get_capability_params(capability)` over a
table of per-stage defaults, and `question`, `research` and
`explore_context` get tables of their own holding the numbers they
already ran on. The pipelines resolve once in `__init__` beside the
budget they already cached. Unknown keys are dropped, so a misspelled
stage cannot become a silent no-op that reads like a setting.
The rule this establishes, stated in the tables: **agents.yaml owns every
LLM budget** (temperature, max_tokens, per stage); **main.yaml owns
runtime behaviour** (iteration caps, timeouts, retry policy, modes). A
budget in main.yaml is a bug. `tool_summarizer.max_tokens` still reads
its main.yaml value first so nobody's existing configuration moves; new
installs reach the same number through agents.yaml like everything else.
GraphRAG's reachability probe is the one documented exemption — tuning it
could only make a health check lie.
Seeds are derived from the same tables the pipelines read, because two
lists of the same numbers is how a default and its seed drift apart —
the shape of #1316. Tests pin both halves: the shipped values, and that
every stage in code is present in the seeded file.
No behaviour change: every default is the constant it replaced.
6902 passed, 24 skipped.
A book built with a reasoning model arrives as a single "Overview"
chapter, or with the right chapter count and every learning objective
and summary empty (#1316). Two independent faults compose into that.
`get_agent_params` maps a module name to a section of agents.yaml, and
`book` was not in the map — so the function returned the source-level
`global_defaults` of 4096 *before* ever opening the file. That budget
was therefore not the shipped default and not overridable: adding a
`capabilities.book` block did nothing, and only editing the source could
change it. It is now mapped, seeded at 12000 in DEFAULT_AGENTS_SETTINGS
(so a stale agents.yaml still gets it), and honoured from the yaml.
12000 rather than a larger figure matches `research`, the closest
analogue, and keeps the request under the output cap of providers that
enforce one.
The budget is the trigger, not the fault. A reasoning model pays for its
hidden tokens out of the same `max_tokens` as its answer, so on a large
prompt asking for a whole JSON object it can spend the lot and emit
nothing. The provider does not raise — it returns a truncated body, or
none — and `parse_json_response` hands back the caller's fallback, which
in `SpineSynthesizer._materialise` is one placeholder chapter. Where the
budget ran out *mid*-object, json-repair closes the fragment and the
caller gets chapters whose objectives never arrived: the same failure
wearing a different face.
`blocks/_llm_writer.llm_json` already knew the escape hatch — ask again
with thinking turned down — but only block generators went through it.
The four pipeline agents each parsed their own response and had no retry
at all. `book/json_retry.py` is now the one place that rule lives, and
ideation, both source-explorer calls, all three spine rounds and the
page planner go through it; `llm_json` shares its predicate so the two
cannot drift. Each caller names the key that proves the payload arrived,
which is what lets a repaired-but-gutted object trigger the retry rather
than settle the stage.
`BaseAgent.call_llm` / `stream_llm` gained the `reasoning_effort`
parameter this needs; it was already the shape `llm_text` used.
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
Fresh installs showed an empty Persona list although the docs advertise
three presets. The presets now ship as package data and are seeded into
the admin workspace on first run (idempotent, non-destructive), so they
appear as read-only presets for every user.
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>
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).
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.
* 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
- Remove CONSOLIDATION_TYPES and explicit consolidation parameter;
auto-consolidate for providers without native answer support.
- Build LLM/Embedding/Search configs directly from resolved runtime
config in ConfigTestRunner instead of relying on global cache.
- Clean up default settings by removing unused consolidation fields.
Made-with: Cursor