Add user attribution to embedding calls — forwards user on OpenAI-compatible providers via current_llm_user(). Excludes LocalAI/Xinference (reject unknown fields). Accepts user_id on ingest/parse/chunk endpoints; redacts from logs. Omitted = unchanged. Go/vision/TTS/ASR out of scope.
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
Fixes a family of table-retrieval truncation bugs and an action-session
infinite loop in the agentic RAG medium path, all root-caused on a
tabular-reasoning question
1. action_session turn cap enforced (action_session.py)
_route checked _pending_calls before attempts, so a model that kept
emitting tool calls never hit the 4-turn finalize — a single session
could burn the whole pass budget (219 retrievals / 600s observed). Added
_route_after_tool: after a tool batch, the turn budget is checked and
the session converges to finalize instead of looping back to run_action.
2. Table chunks kept whole through retrieval (search.py,
text_processing.py, action_session.py)
Three truncation points hid mid-table answer rows from the session
model:
- grep_search narrowed table chunks to 700 chars
(_GREP_OUT_CHARS_PER_CHUNK)
- _narrow_content only passed HTML tables (<table>/<tr/<td) whole —
markdown pipe tables were sentence-window narrowed
- _admit_evidence truncated the model-facing output to 1200 chars even
though the pool held the full chunk,non-table chunks keep the existing
truncation paths unchanged.
3. SCA sees more evidence (agentic_rag_graph.py, sufficient_context.py)
_SCA_VIEW_CAP 24 → 60; _SCA_CLAIMS_CONTEXT_MAX 9000 → 48000;
table-bearing evidence anchors rendered in full (bounded by the context
budget).
4. Supporting: runtime instrumentation for rounds/slots/retrievals, LLM
token accounting, slot-evidence preservation through SCA, dedup
checkpoints. Timeout/budget constants restored to upstream defaults.
---------
Co-authored-by: Loong <213221738@seu.edu.cn>
Co-authored-by: Hermes Agent <hermes-agent@localhost>
Fix non-streaming chat sending empty tools=[] (rejected by strict providers). Restored mdl.is_tools check and added helper to omit tools field when unbound.
Fix agentic search ignoring chat retrieval settings — now passes knn_top_k, weights, threshold, and top_n. knn_top_k critical for HNSW recall on large indices.
Fix#15962 — replace bare assert isinstance in KnowledgebaseService.dfs_update with safe conditions. Stored None values no longer crash table-parser parses. Matches DocumentService fix from #12815.
Fix reasoning + KB requests using models without tool-calling — now fall back to async_chat RAG path instead of answering from general knowledge.
Co-authored-by: Chen Li <george_lichne@163.com>
Fix POST /api/v1/files 500 error when parent_id doesn't exist. Removed dead delete_folder_by_pf_id call (mismatched args, no tenant scope). Now returns False and documented error response.
### Problem
When a chat assistant has a configured system prompt and the reasoning
level is set to anything other than `NONE`, the request goes through
`rag_agent()` / the agentic RAG harness. That path generated the final
answer with a fixed `FINAL_ANSWER_SYSTEM` prompt and never injected the
user-configured system prompt, so the assistant ignored
role/tone/language instructions (reported in #18833).
### What problem does this PR solve?
Closes#18116.
Fix cross-KB document ID collision (#18116). Older ID derivation excluded kb_id, causing two KBs to fight over one row. Unified derivation to be KB-scoped, with fallback for existing rows. Stranded rows are reclaimed, dataset deletion now cleans up state, and upgraded instances update in place. Tests added.
### Summary
Fixes#18653. Groq rejects every chat request on v0.27.0 with `property
'conversationId' is unsupported`, while the same chat works on Ollama.
Closes#18653
Co-authored-by: Jin Hai <haijin.chn@gmail.com>
### Summary
The fix is one line per helper — assign the `order_by(...)` result back
so the
ordering is actually applied to the query.
Co-authored-by: rsnetworkinginc <rsnetworkinginc@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Follow-up to #17526 ("Refactor: merge dataset scope graph"), which introduced two code paths that touch Infinity columns the deployed schema does not declare. This PR makes the runtime robust against the old schema while also adding the new column to the new schema so freshly created tables are correct.