Declare document-scope support at the pipeline contract and reject unsupported scoped queries before rewrite/retrieval; verify empty scopes also fail closed (29 retrieval tests and 10 service tests passed).
Addresses Air R1/R2 review blockers on top of the opened PR head:
Settings GET/PUT /api/settings/web-fetch with UI control; DeepSeek fetch
uses identity encoding, raw bytes, and capacity checks before buffer extend;
provider-branding treats `local` as generic.
Air Codex R3 on MacBook Air: READY.
source_path alone is a document scope, not a visual request: an ordinary
text query with no page, figure, region or asset_id selector now stays on
the text retrieval path, restricted to that one document, instead of
entering exact-source visual inspection and failing reference_required.
- RAGTool routes source_path-only queries to a scoped semantic search that
verifies the source exists (and its source_hash when given), forwards
document_keys to the backend, and never falls back to a whole-KB search:
a backend that cannot enforce the scope, or a document with no matching
passage, fails explicitly (source_scope_unsupported /
source_scope_no_match) with foreign passages withheld.
- LlamaIndex scoped retrieval now recognises plain-text documents, which
carry only file_path metadata, by their raw-relative position — never by
bare basename, so sub/notes.txt does not leak into a notes.txt scope —
and admits nodes without a page_status.
- Tool schema description and en/zh prompt hints state the contract;
selector-contract tests cover the scoped text path and a new suite
covers raw-relative scope matching.
Add a FETCH_PROVIDERS spec table next to SEARCH_PROVIDERS and a
deeptutor/services/fetch/providers registry, mirroring the search-provider
shape: local (the unchanged in-process extractor, default) and deepseek
(POST /v1/tools/fetch, Bearer auth; key from kwargs > env > DeepSeek chat
profile).
fetch_url_as_markdown gains backend=None -> DEEPTUTOR_FETCH_BACKEND ->
local. The scheme/SSRF gate runs before any remote backend so a private
URL is never handed to a third party. Retryable backend failures
(401/402/403/408/429/5xx, network, missing key) fall back to the local
extractor; 400/404/413 and an empty body are hard failures. Remote
outcomes keep the requested URL for citations; the crawler/KB site sync
stay local. All tests mock HTTP offline.
extract_questions_with_llm raises ValueError("LLM returned empty or None
response") when the completion is None, but its except handler then sliced
result_text[:500] — None[:500] — raising TypeError and masking the intended
error. A None completion is a realistic provider outcome (content filter,
transient empty response) in the exam-mimic question pipeline.
Build the preview from (result_text or "") so the handler reports the clean
ValueError.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Twenty tests read repository files (pyproject.toml, SKILL.md, prompt
YAML/Markdown, requirements) or a UTF-8 backup with a bare read_text(),
which decodes with the locale. On a Chinese-locale Windows machine
(cp936) every one of them fails with UnicodeDecodeError before asserting
anything, so the suite cannot be run there to check Windows behaviour.
Pass encoding="utf-8", as the product code reading the same files does.
No assertion changes.
When read_skill asks for a file the skill does not hold, the tool names
the files it does hold so the model can ask again. list_skill_files
built those names with str(relative_to(...)) and sorted Path objects,
so on Windows the model saw "references\outline.md" in case-insensitive
order, not the "references/outline.md" form SKILL.md links use.
Return relative_to(...).as_posix() and sort the strings.
The Docling and MinerU model downloads read their child's output with
text=True and no encoding, so the backend decoded it with the ANSI code
page. Under `deeptutor start` the backend gets PYTHONIOENCODING=utf-8
but not UTF-8 mode, so on a cp936/cp932 server the downloader writes
UTF-8 tqdm bars that the pump cannot decode. The first bar raised
UnicodeDecodeError, the pump stopped reading, the child blocked on the
full pipe and the job stayed "running" with an empty log.
Follow the MinerU parse subprocess: run the downloader with
PYTHONUTF8=1 and decode its output as UTF-8 with errors="replace".
web_fetch decoded every response with httpx's response.encoding, which
only reads the Content-Type header and otherwise defaults to UTF-8. Pages
that declare their charset in the markup (common for GBK, Shift_JIS and
EUC-KR sites) came back as replacement characters in the web_fetch tool,
Immersive Reading URL imports and website knowledge-base crawls.
Pick the charset the way a browser does: byte-order mark, then the
Content-Type charset, then a <meta> declaration in the first 1024 bytes,
then UTF-8. Labels such as gb2312 and iso-8859-1 decode as their
superset encodings (gb18030, cp1252), matching the WHATWG Encoding
standard.
Optional selectors are now advertised as nullable, page is one-based with
minimum 1, and region is four coordinates bounded to 0..1 with omitted/null
meaning the full page. At the tool boundary a legacy empty region counts as
omission instead of switching to visual routing, and malformed page/region
selectors fail visibly with a correctable message instead of being clamped
or rerouted to replacement evidence.
Adapt the journal foundation from PR #1226 and add a read-only mission, handoff and confirmed-record panel. Share its snapshot with turn injection, preserve corrupt files, and serialize worker writes.
Co-authored-by: ZQR1101 <278034003+ZQR1101@users.noreply.github.com>
decode_escaped_unicode_for_display repairs double-encoded \uXXXX runs
(#973) with the unicode_escape codec, which turns a surrogate-pair escape
for an emoji into two lone surrogates instead of one emoji. The
result cannot be encoded as UTF-8, so an ask_user card or mastery question
whose escaped text contains an emoji fails when the event is persisted to
SQLite or sent over the WebSocket.
Decode each run as a JSON string instead, matching the web decoder's
JSON.parse, and leave runs with an unpaired surrogate escaped.
Local parse failures were flattened into one 'Ensure MinerU is installed or switch to cloud mode' error even when the CLI existed and the run failed at runtime, and the captured stderr tail only reached the server console. Map each LocalParseReason to its own MinerUError message (install hint only for cli_missing, stderr tail for nonzero_exit) and carry code/detail on MinerUError. The four white-box tests that injected the old bool function now inject parse_document_with_mineru_result; assertions are unchanged.
_request_json used a fixed two-attempt loop, so with N configured keys
only the first two were ever tried before MinerUError was raised after
consecutive 429s. Follow the #1499 retry-budget semantics used by the
LLM/embedding paths: attempts = max(2, len(key_pool)).
Behavior is unchanged for single- and two-key setups; pools with three
or more keys can now actually rotate past two rate-limited keys.
* fix(skills): distinguish missing skill files
* review: bound the file listing, drop the scolding
Naming a skill's actual files is the right fix — it tells the model the path
it should have asked for instead of leaving it to guess. Two corrections.
`list_skill_files` walks `rglob("*")` with no ceiling, so a skill carrying a
references tree answered a wrong path by reciting its whole inventory into
the turn. Capped at 40, and it says how many it withheld.
"Do NOT try other skill names." was a rule aimed at the model in the middle
of a result. The message already resolves the skill and lists its files, so
the structure says the name was fine and only the path was wrong; the
instruction was restating that in a louder voice.
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>
* feat(knowledge): add KB frontier discovery tool
* review: let agents.yaml own the query-derivation budget
`reason()` falls back to agents.yaml when the caller says nothing, which is
where every LLM budget in this codebase lives. 512 tokens is also the shape
that starves a reasoning model before it emits a single query — it spends the
allowance thinking and returns nothing, which is how #1318 shipped.
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>