243 Commits

Author SHA1 Message Date
Axton Ji
04eb2ac82e fix: batch indexing journal writes for per-document status updates (#3137)
IndexingRun.document() re-reads the journal and atomically rewrites the
whole .indexing-run.json on every call. The LlamaIndex loader marks each
accepted source "embedding" in a synchronous loop on the event loop, and
publication marks every loaded Document (one per page) "completed" the
same way, so recording n statuses costs O(n^2) bytes of I/O with no
await in between. On a 4,320-document reindex this held the loop for
over 100 s, /health/ready stopped answering, and the desktop supervisor
killed the core.

Add IndexingRun.documents(sources, status, **details), which applies one
status to many sources under a single ownership check and a single
journal write, and use it from the loader, the LlamaIndex publication
step and the RAG service's indexed-file callback. document() now
delegates to it, so single updates behave as before.

Fixes #3046

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 16:56:02 +08:00
zhang.kom
a4d1cf7499 fix: allow inferred embedding dimensions in LlamaIndex preflight (#3138) 2026-12-01 09:33:49 +08:00
Leveling
41fdf08b92 fix(rag): size the docstore count cache to the catalogue, not one KB (#2777)
A KB-list / get_info sweep probes every version-N directory of every KB,
because the UI renders readiness per version. The docstore count cache is
keyed per version directory, so its capacity has to cover the whole
catalogue, not a single KB's worth.

At the old fixed 128 slots a real installation (13 KBs, 310 version
directories -- #2772) exceeded the working set on every sweep: each probe
evicted exactly what it had just read, the hit rate stayed at a permanent
0%, and every UI navigation re-parsed every multi-MB docstore.json. On a
memory-constrained host that showed up as a pinned event loop and hundreds
of GB of disk reads.

Raise the capacity to 4096. Each entry is a path plus an int, so this costs
about a megabyte even well above the working set.

Reproduced against v1.7.3 with a fixture matching the report (13 KBs, 310
versions, 52 MiB of docstore.json), replaying inspect_kb_versions() per KB:

  before: 310 / 310 / 310 / 310 / 310 docstore parses per sweep, 0.0% hit rate
  after:  310 /   0 /   0 /   0 /   0 docstore parses per sweep, 100% warm

A rewritten docstore still invalidates correctly (doc_count 400 -> 1), and
unchanged versions stay cached. The new regression test builds 2 KBs x 100
versions, which is above the old cap, and fails on the unfixed code
(400 parses instead of 200).

Closes #2772
2026-11-30 23:21:42 +08:00
AleFlyX
fea1be2c97 Merge PR #3092: fix(rag): reuse completed BM25 sidecars on rebuild retry
Verified that the retry published the index with one BM25 write across both attempts. The simulated merge into dev passed 40 targeted tests.
2026-11-30 19:08:21 +08:00
lipeh1
681b23766f feat(rag): support local rerankers for LightRAG queries (#3009)
* feat(rag): support local rerankers for LightRAG queries

Allow administrators to select a cross-encoder alongside the native LightRAG role models. Run scoring in a reusable worker and partition cached answers by reranker so model changes take effect on existing indexes.

Refs #2701

* fix(api): refresh the router index for LightRAG settings

* fix(rag): run LightRAG reranking in the shared reranker worker

anyio's process pool re-runs the server's __main__ file by path. When the
backend runs as `python -m deeptutor_cli.main serve` (the desktop app),
that file's relative imports fail, so every rerank call failed with
'Error during worker process initialization' and LightRAG silently kept
the original chunk order. Reuse the python -m reranker worker that the
LlamaIndex pipeline already uses.

---------

Co-authored-by: lipeih <lipeihan@eazytec.com>
Co-authored-by: zszz3 <zszz3@users.noreply.github.com>
2026-11-30 18:46:49 +08:00
Gaurav Dubey
8b4191b7d1 fix(rag): keep figure captions out of the chunk metadata budget (#2870)
* fix(rag): keep figure captions out of the chunk metadata budget

Figure documents carried the caption, asset ids, bbox, source locator and
absolute path in metadata that LlamaIndex counts against every chunk. A long
caption (common for CJK textbook figures) pushed the metadata past the
default 512-token chunk size, so SentenceSplitter raised "Metadata length
(...) is longer than chunk size (512)" and the whole indexing run failed.

Keep those keys on the node for citations and pixel delivery, but exclude
them from the embed and LLM metadata text. The caption is already part of
the document text, so retrieval content is unchanged.

Closes #2865

* test(rag): split sentences without NLTK in the caption budget test

The new regression test ran SentenceSplitter with its default punkt
tokenizer, which loads NLTK data. CI runners refuse that data, so the
test failed with LookupError on all Python versions. Pass a regex
sentence splitter instead. The test still fails without the loader fix.
2026-11-30 04:18:49 -03:00
AleFlyX
813827448b fix: 重试知识库重建时复用已完成的 BM25 索引
变更
- 重试时校验 BM25 与当前文档存储是否匹配,缺失、截断或过期时补建。
- 覆盖旧快照、截断文件和中断后清理失败的回归场景。

验证
- 76 项 LlamaIndex 和 BM25 定向测试通过。
- 缩短超时的复现中,修复后只写一次 BM25,重试成功发布。
- Ruff 检查、格式检查和 git diff --check 通过。

Related to #2837
2026-11-30 14:57:12 +08:00
muhamedaldias
084d311302 fix(rag): skip CancelledError results in SmartRetriever.retrieve (#2981)
Co-authored-by: muhamedaldias <296670347+muhamedaldias@users.noreply.github.com>
2026-11-30 14:18:33 +08:00
enlightenmengt2
9ec5815df5 fix(rag): register connected engines in the preflight registry (#3027)
EngineDetail renders the readiness panel for every engine, and its check button calls /api/knowledge-bases/rag-pipelines/{provider}/preflight, which runs engine_preflight() -> _PREFLIGHTS[normalize_provider_name(provider)]().

weknora and kiwix are in KNOWN_PROVIDERS but were never registered in _PREFLIGHTS, so the lookup raised KeyError and the route answered 500 for those engine pages.

One shared _connected_preflight now reports them ready: each knowledge base supplies its own server URL and credentials, validated by the connect probe, so nothing is configured account-wide. This matches doctor.py, which already skips these providers in its preflight loop.

The new test walks KNOWN_PROVIDERS and asserts every entry returns a report, so a future provider constant cannot silently miss the registry again.

Co-authored-by: enlightenmengt2 <227120787+enlightenmengt2@users.noreply.github.com>
2026-11-30 14:17:55 +08:00
Leon Lei
9db50a7601 fix(rag): avoid NLTK regex CPU timeout in sentence splitting and clean failed version dirs (#3036)
* fix(rag): avoid NLTK regex CPU timeout during splitting and clean failed version dirs

* fix(rag): construct PunktSentenceTokenizer directly without globals_helper stopwords
2026-11-30 14:17:37 +08:00
Carl
c1ae1bbe2a fix(rag): isolate LlamaIndex cross-encoder reranker in a worker process (#3005) 2026-11-30 14:17:26 +08:00
AleFlyX
be2fe9104d Merge PR #2837: fix(rag): batch LlamaIndex rebuild checkpoints
Batch resumable embedding checkpoints and write the BM25 sidecar once after the final checkpoint, carrying over #2903. 45 targeted tests passed with the PR applied to dev. A 19-source rebuild retrieved the last source from the persisted BM25 index.
2026-11-29 16:32:15 +08:00
wojiecihuo
3035ab27e0 fix(rag): keep RERANK_BY_DEFAULT when a LightRAG reranker is wired (#2994)
#2708 set enable_rerank from whether a rerank model is wired, which also
overrode LightRAG's RERANK_BY_DEFAULT switch once a reranker exists. Only
turn rerank off when no model is wired and otherwise leave LightRAG's
default in place.
2026-11-26 22:50:37 +08:00
游标卡尺
186accef49 fix(rag): only request LightRAG rerank when a rerank model is wired (#2708)
LightRAG 1.5.7 defaults enable_rerank on, so query_with_sources emitted a
per-query warning whenever no rerank model was configured. Gate the flag
on the presence of a callable rerank_model_func so the default deployment
stops warning without changing behavior for anyone who wired a reranker.

Co-authored-by: ZQR1101 <278034003+ZQR1101@users.noreply.github.com>
2026-11-26 22:30:07 +08:00
AleFlyX
9199e923cf fix(rag): persist BM25 once after the final rebuild checkpoint
Integrate AleFlyX's staged sidecar write from PR #2903 with the batched checkpoints in PR #2837. Rebuild the sidecar after the final checkpoint, including when resuming a fully checkpointed candidate.
2026-11-23 22:48:55 -03:00
Qiuner
9186666b43 fix(rag): batch resumable LlamaIndex checkpoints 2026-11-20 23:25:11 -03:00
Bingxi Zhao (Frank)
18e491d346 fix(rag): surface IMA content restrictions and seed retrieval failures 2026-11-15 01:04:25 +08:00
Bingxi Zhao (Frank)
92a26ae3cc fix(storage): isolate attachment writes and settle document parsing
Local dev repairs for #2244, #2245, #2255, #2426, #2453. Regression checks cover reported symptoms and compatibility boundaries.
2026-11-15 00:44:09 +08:00
Bingxi Zhao (Frank)
794f1c7399 Merge PR #2545: fix: scope text source_path RAG to the requested document (#2374)
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).
2026-11-14 23:16:26 +08:00
lazytalk
9e20ebc9d7 fix(knowledge): skip unreadable index versions instead of failing the KB list
A knowledge base whose data files are unreadable (for example root-owned
files in a container whose app runs as uid 1000) used to take down the
entire KB catalogue: list_kb_versions() -> _read_json() -> Path.exists()
raised PermissionError, so list_knowledge_bases() and the web-source
scheduler failed for every KB.

- _read_json() opens the file directly and treats FileNotFoundError as
  "no metadata"; other OSError/ValueError degrades to a warning. This also
  avoids Path.exists(), which propagates EACCES on Python >= 3.8.
- _is_storage_ready(), _flat_version_dirs() and list_kb_versions() skip
  unreadable versions with a warning instead of raising.
- KnowledgeBaseManager._list_knowledge_bases() isolates per-KB failures
  and an unreadable base directory, keeping the rest of the catalogue.

Tests cover unreadable metadata, an unreadable version dir, an unreadable
storage probe, and a manager listing with one unreadable KB.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-09 22:49:11 +08:00
evan188199-tech
1cd7e2e150 fix: match scoped RAG sources by exact path (#2374) 2026-11-09 16:28:24 +08:00
evan188199-tech
2103f2523c fix: scope text source_path RAG queries to their document (#2374)
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.
2026-11-09 15:07:50 +08:00
Bingxi Zhao (Frank)
81ed91a8c3 Keep scoped embedding clients on their calling operation and split mastery-only UI 2026-11-06 02:25:50 +08:00
Bingxi Zhao (Frank)
c47b777884 Merge #2457 from wangjianming 2026-11-06 02:16:48 +08:00
Bingxi Zhao (Frank)
823aa1a8b3 Validate launcher, retrieval, migration, and responsive reader behavior 2026-11-06 02:04:53 +08:00
Bingxi Zhao (Frank)
05c5d90e35 Merge #2351 from rahul05ranjan 2026-11-06 01:56:40 +08:00
Bingxi Zhao (Frank)
8602605976 Merge #2336 from remote-controlled-man 2026-11-06 01:56:40 +08:00
Bingxi Zhao (Frank)
2c60615a04 Merge #2410 from chen-12-03 2026-11-06 01:56:25 +08:00
Bingxi Zhao (Frank)
d731546cf6 Merge #2379 from remote-controlled-man 2026-11-06 01:56:25 +08:00
Bingxi Zhao (Frank)
d374d7e26a Merge #2332 from markjoin123 2026-11-06 01:56:23 +08:00
wangjianming
c55d55abfd Keep LlamaIndex embedding setup off the event loop
The first KB query builds the embedding adapter (provider SDK import and client construction) inside the coroutine, which blocks every other task on the loop for seconds. Run it in a worker thread; scoped embedding configs keep their ContextVar branch inline.
2026-11-05 16:53:55 +08:00
chen-12-03
739f6406a3 fix: avoid quadratic source image path matching 2026-11-03 21:01:09 +08:00
Steven Huang
b4dab154da fix: retain inferred source page inspection 2026-11-02 22:22:18 +08:00
Rahul
a141132c54 fix(ima): report never-extractable items as unsupported_format
_hydrate now records a precise failure for sources skipped for their
title's format instead of leaving them as bare content_unavailable.

Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
2026-11-02 12:14:12 +05:30
Rahul
47595d6fa8 fix(ima): skip hydration targets whose title names an unextractable format
Legacy Office documents and other engine-only formats pass the IMA title
check but can never yield text through the built-in extractor, so a full-text
fetch only burns the 4-document hydration budget ahead of extractable
matches. Skip them at target selection and report them as
unsupported_format instead of an unexplained content_unavailable (#2338).

Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
2026-11-02 12:14:10 +05:30
Steven Huang
466649209a fix: handle adjacent identifiers and reuse BM25 rebuilds 2026-11-02 11:04:42 +08:00
Steven Huang
02339d5065 fix: preserve dotted identifiers in BM25 retrieval 2026-11-02 10:32:25 +08:00
markxu
db014f0ed8 fix(ima): route search folder-name hits away from document hydration
search_knowledge returns folder matches inside info_list with a folder_
media id and media_type 99, and no folder_id. Those were parsed as
documents, so retrieval spent the hydration budget on get_media_info
failures and reported content_unavailable.

Fixes #2326
2026-11-02 02:04:30 +00:00
Rudy Celekli
b71c2b7e3a fix(rag): count LightRAG docs from the native workspace store
The LightRAG index probe reported doc_count=None for every native-layout
index. _lightrag_doc_count read kv_store_doc_status.json from the version
root, but native LightRAG keeps its KV stores under a deeptutor_<hash>
workspace subdir; every other reader (has_output, failure_summary,
document_error) resolves that subdir via storage._store_root first.

Move the count into the storage module as a public doc_count() that
resolves the store root the same way, and have index_probe delegate to it.
A ready native index now reports its real count instead of None, so the KB
version list, last_indexed_count and linked-folder probe stop falling back
to a raw-file guess.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-01 09:10:24 -05:00
Bingxi Zhao
34e316388c Merge pull request #2208 from fanjiahe/fix/llamaindex-version-retention
fix: publish one LlamaIndex version per folder sync
2026-10-31 18:49:18 +08:00
Bingxi Zhao
94d71357bf Merge pull request #2188 from Zhi-Xiang-Guo/fix/rag-exercise-scope-evidence
fix(rag): preserve selected-document exercise retrieval and usable page evidence
2026-10-31 18:27:09 +08:00
Bingxi Zhao
8e6c40cab0 Merge pull request #2223 from markjoin123/cursor/fix-pdf-ref-list-indexing-29e3
fix(rag): index MinerU reference lists and skip page furniture
2026-10-31 17:54:24 +08:00
Bingxi Zhao
ac75e456f1 Merge pull request #2211 from Rimcat-JA/fix/rag-drop-unmatched-bm25
fix(rag): keep zero-score BM25 hits out of hybrid fusion
2026-10-31 17:32:50 +08:00
Bingxi Zhao (Frank)
74a49500a7 fix(rag): keep batch publishing independent of version retention 2026-10-31 16:44:19 +08:00
markxu
17104645cd fix(rag): index MinerU reference lists and skip page furniture
build_pdf_documents() ignored MinerU list_items, so bibliography entries
on type=list / sub_type=ref_text blocks never reached the chunker.
Page-number, header, and footer blocks were indexed instead.

Fixes #2222
2026-10-31 02:07:06 +00:00
fanjiahe
cfd1e2e3b6 fix: publish one LlamaIndex version per folder sync
Linked-folder sync wrote a full snapshot for every file and never deleted the old ones. Index a staged batch in one publish and keep the newest three snapshots per embedding signature.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-31 00:53:47 +08:00
Rimcat-JA
eee09e311f fix(rag): keep zero-score BM25 hits out of hybrid fusion
BM25Retriever returns its top-k nodes even when no query term matches.
With the default whitespace tokenizer that happens for every Japanese or
Chinese query, and reciprocal-rank fusion ranks those score-0 nodes like
real lexical hits, so unrelated chunks land in the top results.

Wrap the lexical side of both fusion retrievers so only hits with a
positive score are fused. Queries that do share terms are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 01:50:03 +09:00
Xiang
8fdbc7f184 fix(rag): preserve selected-document exercise evidence
Retain exact exercise lookup with scoped canonical page evidence and fall back when provenance is unavailable. Cover real lesson preparation and selection boundaries.
2026-10-30 17:12:57 +08:00
wangkai
b19e281b82 fix(rag,session): read coverage and cost reports as UTF-8
The visual-coverage report and recovered usage reports are UTF-8 JSON
written by this codebase, but were read through the locale default.
Non-ASCII titles made coverage fall back to unverified and cost recovery
silently lose per-model details on Chinese Windows.
2026-10-29 13:33:14 +08:00
Bingxi Zhao (Frank)
b89748200a Merge pull request #2109: Claude Agent SDK provider 2026-10-29 01:07:23 +08:00