The research, question and page-index loops (run_labeled_step) and the context explorer call the SDK client directly, so an anthropic/ model on OpenRouter got no cache_control breakpoint and cached nothing on any round. Move the chat loop's check into runtime/agentic/prompt_caching.py and apply it in all three places. Refs #3087.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J2vr2J41oqPYhmpP8CzSJA
* fix(llm): force temperature 1.0 for gpt-6 and treat reasoning_effort+tools rejection as tool-schema unsupported
* fix(llm): drop reasoning_effort instead of tools when combined request is rejected
---------
Co-authored-by: Shaikh Fardin <152140625+Fardin7798@users.noreply.github.com>
Co-authored-by: OrdoAbChao7 <2369980241@qq.com>
AnthropicProvider and the agentic client's Anthropic adapter fell back to claude-sonnet-4-20250514, which Anthropic retired on 2026-06-15, so an Anthropic binding with no model failed with not_found_error. Both now use one DEFAULT_ANTHROPIC_MODEL constant, claude-sonnet-5-5.
CallToolTool answered every unforwarded call with "load it first". That
was wrong for a tool already in tools[] (an MCP tool, a built-in) and for
malformed arguments, and for the former it sent the model round in a
loop. DeferredToolLoader.proxy_refusal now names the reason (missing
name, call_tool itself, already in the tool list, proxy off, unknown,
not loaded) and proxy_arguments checks the arguments: an object, or a
string holding valid JSON for one; anything else is refused. The
pipeline's _resolve_proxied_tool_calls and CallToolTool both go through
proxy_call_refusal, so the message matches the decision.
Setup tools loaded through load_tools are proxied. Opening setup mode
later left them proxied: not in tools[], no rules (already loaded), and
a note that never mentioned call_tool. An opened mode's tools are now
made native, like mastery's outline tools; a setup turn whose tools are
still proxied gets a hint to reach them through call_tool.
Also: call_tool is mounted only when the loader has built-in/capability
tools to proxy; its manifest order no longer duplicates load_tools'; a
forwarded call without an id is not marked for renaming.
Refs #2972
load_tools appended the loaded schema to the end of tools[]. tools[] is the
first thing in the provider's prompt-cache key, so the next request of the
same turn re-processed the system prompt and the whole history.
When the turn mounts the new call_tool builtin, load_tools now returns the
loaded tools' definitions in its result and leaves tools[] alone; the loop
forwards each call_tool call to the named tool before dispatch, so the tool
runs with its own argument checks, injected kwargs and trace, while the
history keeps the model's own call. Tools loaded this way stay proxied for
the session (loaded_tools.json gains proxied_tools). Runtime loads that must
land in tools[] pass native=True; the TypeScript engine keeps the old
behaviour.
SetupCapability.turn_note and the legacy setup system block now read the
header, gap-list heading, intro section and explicit/intent/intro leads from
capabilities/setup/prompts/{en,zh}/notes.yaml (overridable under
setup.notes.<key>); the intro section gains a Chinese version. The Extended
Tools manifest header no longer says every entry is supplied by an external
service, since built-in setup and research tools are listed there too.
* fix(reading): isolate document ingestion from the API process
(cherry picked from commit f0fd1f785eb1070f689816b0977bf4c60125f95a)
* chore(api): refresh router index for the reading routes
---------
Co-authored-by: zszz3 <zszz3@users.noreply.github.com>
* fix: keep mastery prompt prefix stable across mode switches
* fix: load the outline tools together when a turn switches to outline
A study turn that switched to outline loaded mastery_build alone through load_tools; the next turn, in outline mode, mounts every outline tool eagerly, so its tools[] carried one schema more than the previous request and missed the whole cached prefix. The mode switch now loads the outline group into the live request at once. Refs #2922
* fix: close loaded tool schemas the same way as mounted ones
Mounted schemas go out with additionalProperties: false; a tool loaded through load_tools did not, so the same tool had two byte forms in tools[]. A tool that moved between mounted and loaded across turns (mastery_build/mastery_revise after an outline->study switch) rewrote the start of the cached prefix. Refs #2922
* fix: keep the outline tools on the deferred loader in outline mode too
Outline mode mounted mastery_build/mastery_revise eagerly and skipped the
loader, while study and review reached them through it. On an install with
no other deferred tool that also dropped load_tools on outline turns, so
tools[] changed in both directions around every switch. Refs #2922
* fix: mount mastery navigation from the first mastery turn
The first mastery turn usually creates the topic; navigation mounted only
once a topic existed, so the second turn's tools[] grew by three schemas and
missed the whole cached prefix. Refs #2922
* fix: send only the current mastery mode's rules, as a runtime snapshot
The system prompt carried all three mode sections so a mode switch would
not rewrite the cached prefix, but that showed the model three conflicting
rule sets and relied on a one-line snapshot to pick one. Keep only a short
frame in the system prompt and send the current mode's own section inside
the mastery_session_mode snapshot, which is appended only when the mode
changes.
Refs #2922
* fix: keep capability tools recorded by another turn in the session's loaded set
A mastery turn records its outline tools (mastery_build, mastery_revise) in
the session's loaded_tools.json so a later study turn keeps the same tools[].
A plain chat turn of the same session builds a provider loader without
capability names; with an unrestricted caller it treated those names as
stale and persisted the set without them, so the next mastery turn mounted
fewer tools and re-paid the cached prefix.
DeferredToolLoader now keeps names it cannot serve (registered tools it does
not own, or names outside its allowlist) as retained: never mounted or
reported, but written back with the session state. Only names whose tool is
gone from the registry are dropped.
Refs #2922
* 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.
Independent maintainer review approved for 257c5e62. Windows Python 3.12 pre-commit 15/15, targeted Windows and WSL Linux regressions passed; latest HEAD CI has no failures.
Local dev repairs for #2168, #2631.
Real child-process recovery: 16 tests passed, including queued, running, waiting_input, process exit and PID reuse. Existing coordination/application tests: 65 passed, 10 optional Redis skips.
`mastery_status` receives `_working_brief` from the mastery loop
(capabilities/mastery/loop.py:436) and reads it as a trusted switch for
whether to project the working brief (capabilities/mastery/tools.py:915).
It was not in RESERVED_ARGUMENT_NAMES, so a model could send
`_working_brief: false` and the tool would honour it.
Same class as `_learner_message`: an injected name treated as fact while
the model can write it. Caught on a later audit pass rather than by any
test, which is the argument for the follow-up in #2610.
`_`-prefixed names reach tools as provenance: `_learner_message` is the
learner's own words, `_sandbox_mounts` is where the turn may write,
`_turn_id` is which turn produced the call. A few of them gate credit or
sandbox access.
Nothing enforced that on the way in. A model emits arbitrary JSON and the
dispatch path never rejected a name it did not expect, so a model could
write `_learner_message` itself and have a built-in tool believe it. That
is how `mastery_grade` came to accept a model-authored answer as grounds
to overwrite a committed learner answer (#2595).
Withhold a fixed list of the names the runtime injects, at bind time,
before the augmenter runs. Adapter arguments outside that list are left
alone, so an MCP server publishing `_id` keeps working.
Also record the filtered arguments rather than the raw JSON. `_rebind`
replays the recording straight into the augmenter, so keeping the raw one
let any round containing a rebinding tool — `ask_user` and
`workspace_export` always qualify — re-admit a forged name the first bind
had already dropped.
Document selected-text speech, model discovery, NVIDIA NIM embeddings,
mastery reliability, Windows improvements, and complete desktop downloads.
Sync all eleven README translations and archive the v1.7.0 release notes.
Add platform-specific typing annotations for Windows APIs without changing
runtime behavior. See assets/releases/ver1-7-2.md for changes and upgrades.
Validation: pre-commit and Ruff passed; 12,782 Python tests passed
(51 skipped), 1,349 Node 22 tests passed, and the docs build passed.
Use CREATE_NO_WINDOW so the venv redirector interpreter inherits a hidden console. Preserve the separate process group and update the Windows launch regression. Fixes#2421.
Co-Authored-By: Codex <noreply@openai.com>
run_labeled_step returned tool calls via the accumulator's raw ordered()
view, which keeps id="" when a provider streams a tool call without an id
delta. The sibling consumers use collected(), which applies the positional
id and arguments fallbacks. Switch to collected() so a tool call made by an
id-less gateway is still correlatable and passes the non-empty-id schema.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>