The wait row only appeared once a completed knowledge_search step existed, so
attachment-only turns (attachment_parsing / image_analysis with no KB hit) still
showed nothing between the last step and the first answer token. Model waiting is
now a three-state kind: 'model' after retrieval finished, the neutral 'preparing'
row otherwise.
A dropped SSE connection never sets is_completed (the stream layer only raises a
toast), so the row used to promise an answer forever. It now stops claiming
progress after RAG_WAIT_STALL_DELAY_MS and drops the shimmer.
Also share RAG_RETRIEVAL_TOOL_NAMES instead of repeating the knowledge_search /
search_knowledge alias check, name the reveal delay, and move the reveal/stall
timers into a controller with an injectable scheduler so the timing is covered by
tests instead of by source-matching alone.
Co-authored-by: lyingbug <lyingbug@users.noreply.github.com>
Follow-up to the error_message clearing added for SetFinalizing,
FinalizeSubtask and ProcessDocument. Two routes still persisted a
previous attempt's failure message:
- ProcessManualUpdate flips a row back to 'processing' without clearing
error_message. A manual knowledge item that failed earlier (for
example when the knowledge base lookup failed, or after an Asynq
retry) re-enters processing still carrying that message, so the UI
shows a failure on a document it also shows as running.
- finalizeIndexedKnowledgeState is the only route to 'completed' that
bypasses FinalizeSubtask. When a document has no text chunks and no
pending multimodal work it is completed in place, so the promotion
that would otherwise clear the column never runs and a successfully
indexed row keeps reporting the earlier failure.
The 'processing' transition is extracted into markKnowledgeProcessing so
ProcessDocument and ProcessManualUpdate share one definition of what
starting a new attempt means, and a future worker cannot reintroduce the
same omission. The helper also replaces the "processing" string literal
with types.ParseStatusProcessing.
Tests: markKnowledgeProcessing gets direct coverage, and the
finalizeIndexedKnowledgeState table now seeds a stale error_message and
asserts it survives the processing branches (FinalizeSubtask clears it
later) and is cleared on the completed branch.
A knowledge item that failed once keeps error_message set; when it is
reprocessed or driven through the finalizing pipeline, the stale message
was never cleared, so the UI kept showing an outdated failure on items
that were processing or had completed successfully.
- SetFinalizing and FinalizeSubtask now clear error_message in the same
atomic UPDATE that transitions parse_status
- ProcessDocument clears knowledge.ErrorMessage when flipping the row
to processing for a new attempt
Add a SQLite-backed regression test covering both transitions.
GET /shared-knowledge-bases returns rows with nested knowledge_base
(sharedKBRow), unlike GET /knowledge-bases which returns flat KB objects.
resolve_kb_id and agent_chat preflight were reading top-level id/name,
so shared KB names never matched. Add _normalize_kb_entries and tests.
resolve_kb_id now searches both own and shared knowledge bases when
resolving a name to UUID. Error messages and docstrings in hybrid_search,
chat, and agent_chat now reference list_shared_knowledge_bases as well.
Co-Authored-By: Claude <noreply@anthropic.com>
Add a new MCP tool to list knowledge bases shared from other workspaces
via the GET /shared-knowledge-bases endpoint, which was previously not
exposed through the MCP server.
- Add WeKnoraClient.list_shared_knowledge_bases() method
- Register list_shared_knowledge_bases() as an @mcp.tool()
Co-Authored-By: Claude <noreply@anthropic.com>
The xlsx URL-import fix left the accepted extension set reachable through two
indirections and widened ApplyKnowledgeProcessOverrides to gate file types for
callers that are not file imports (web URL fetch, connector sync, reparse).
Collapse the set into one map that both isValidFileType and the extension check
read, move the shared validation next to the other file-type predicates, and
return ApplyKnowledgeProcessOverrides to its override-only scope so
resolveFileImportProcessConfig is the only import gate.
Also drop the unreachable branch in createKnowledgeFromFileURL: getFileType
never yields an empty string, so the resolvedFileType fallback and its else arm
could not run. Normalize the resolved type before it reaches the record and the
task payload, and add an invariant test asserting direct upload and URL import
accept the same extensions so #2447 cannot drift back.
Extract shared file-import checks (type, VLM/ASR, video) into
resolveKnowledgeFileImportConfig and reuse them for file URL import.
Also enqueue DataTableSummaryTask for spreadsheet URL imports and reparse.
Embed visitors have no Bearer token, so resource:// images must be fetched
via /api/v1/embed/:channelId/files. Centralize proxy selection in a
protected-file access context and register the embed plane at EmbedPage so
deep renderers like AgentStreamDisplay no longer fall back to /files (401).
Re-add flat-key translations for audit log and knowledge-base activity events
that were dropped or nested incorrectly during i18n pruning. Add a shared
action registry, English defaults, and prune safeguards so regenerate-i18n-locales
reads the working tree and cannot strip these runtime keys again.
Align agent and knowledge base editors so edit saves close the modal,
first-time create stays open with contextual footer hints, and follow-up
actions point users to sharing/integration or data-source configuration.
Two issues caused retrieval metrics (precision, recall, NDCG, MRR, MAP)
to always be 0:
1. recordFinish compared SearchResult.ChunkIndex (the chunk's ordinal
position in the knowledge base) against QAPair.PIDs (the dataset's
original passage IDs). These are different ID spaces that never match.
Fix: use content-based matching to map each retrieved chunk back to
its source passage, with deduplication for multi-chunk passages.
2. getPassageList had an off-by-one error: make([]string, maxPID) with
loop i < maxPID dropped the passage with the highest PID.
Fix: use maxPID+1 and i <= maxPID.
Also adds fallback from rerankResult to searchResult when no rerank
model is configured, matching the pattern in the working copy.
EvalDataset used CreateKnowledgeFromPassage (async), which returns
immediately while chunking/embedding/vector-indexing runs in the
background. The subsequent RAG queries then hit an empty vector store,
so retrieval metrics (precision, recall, NDCG, MRR, MAP) were always 0.
Switch to CreateKnowledgeFromPassageSync, which waits for indexing to
complete before returning — the same pattern already used in
web_search.go for the identical create-then-query flow.
Match Milvus/Tencent VectorDB and CLI semantics where threshold 0
means no score floor, and add a regression test for anti-correlated
vectors that would otherwise be dropped.
Rename the distribution to tencent-weknora-mcp, point metadata at
Tencent/WeKnora, bump to 1.1.1 for the transport/session fixes, and
tighten publish to main/tags only via Trusted Publishing.
Keep stateless HTTP and /sse/messages/ paths aligned with pre-2.x behavior,
use thread-local requests.Session for concurrent tool handlers, and add
transport regression tests.
MCP Python SDK 2.0 removed the low-level Server decorator API
(@app.list_tools() / @app.call_tool() / app.get_capabilities()), so the
server crashed at startup with:
AttributeError: 'Server' object has no attribute 'list_tools'
The released PyPI package weknora-mcp==1.0.1 declared 'mcp>=1.0.0' with
no upper bound, so uvx resolved to the latest 2.0.0 and the plugin's
weknora MCP server could no longer connect.
Fix: rewrite the server on top of the mcp 2.x high-level MCPServer API
(formerly FastMCP), and cap the dependency at 'mcp>=2,<3'.
- weknora_mcp_server.py: replace @app.list_tools()/@app.call_tool() with
28 @mcp.tool() function-signature tools (input schema auto-generated
from type hints, descriptions from docstrings, plain return values
serialized by the framework). Transports use run_stdio_async() /
sse_app() / streamable_http_app(). WeKnoraClient business logic is
unchanged.
- deps: mcp>=2,<3 in pyproject.toml / requirements.txt / setup.py;
commit uv.lock pinning mcp 2.0.0.
- version bump to 1.1.0 (pyproject, setup, __init__, main --version,
server_version).
- check_imports.py: validate MCPServer / ToolError / mcp_types imports.
- ci(.github/workflows/mcp-server.yml): publish on merge to main +
manual dispatch, not only on tags; add PyPI version-dedup check so
re-runs on an unchanged version stay green (absorbed from PR #2399).
Verified: stdio initialize + tools/list returns all 28 tools; no
list_tools AttributeError; tool dispatch + error wrapping confirmed.
Co-authored-by: wizardchen <wizardchen@tencent.com>
Compare base...head for pull_request events instead of the merge commit
so unrelated main-branch files are not checked. Also gofmt
kb_access_test.go, which was unformatted on main.
Use setup-go v6 default go.mod cache key instead of go.sum, warm the
module cache with an explicit go mod download step, and scope vet to the
same package set as tests.
Start the DocReader gRPC server in the DocReader workflow, skip client
integration tests when the server is unavailable, exclude docreader
packages from the App workflow test scope, and trigger DocReader checks
on go.mod/go.sum changes.
Reject invalid agent_source_tenant_id instead of silently falling back, fix a resolveAgent nil panic when a shared selector fails, and add regression tests for wiki write-tool filtering and agent resolution.