Advanced Search and Agent Retrieval
Use the current Hybrid Search API, Remote MCP tool, and iterative knowledge-base retrieval available to Customize Model agents.
UnieAI Studio uses Hybrid Search for direct knowledge-base queries. Customize Model agents build on the same retrieval engine by choosing focused queries, searching again when necessary, and combining evidence from their linked knowledge bases.
The current product does not expose auto, hyde, multi_query, rerank, or combined search modes. The Studio Search page, REST API, and Remote MCP tool support hybrid only.
Choose the correct search path
| Path | Scope | Who controls the query | Main parameters |
|---|---|---|---|
| Knowledge base Search page | One knowledge base | User | Limit, Min score |
POST /v1/kb/search | One authorized knowledge base | Calling application | kb_id, query, limit, min_score, document_id |
Remote MCP kb_search | One authorized knowledge base per call | MCP client or agent | kb_id, query, limit, min_score, document_id |
| Customize Model agent | All knowledge bases linked to the model | Base model through tool calls | Focused query and result limit; model RAG settings provide the retrieval threshold |
The first three paths return chunks. They do not generate a final answer. A Customize Model agent can retrieve evidence and then use its base model to compose an answer.
Direct Hybrid Search
Every direct query runs Dense vector retrieval and BM25 lexical retrieval. Runtime merges both candidate sets, calculates a Hybrid relevance score, applies min_score, sorts the chunks, and returns up to limit results.
Use a natural-language question when meaning matters. Keep exact identifiers, clause numbers, product names, and error codes in the query so BM25 can preserve those signals.
REST API
Send the request to the Runtime Base URL, not the Studio website URL:
curl -X POST "$UNIEAI_RUNTIME_BASE_URL/v1/kb/search" \
-H "Authorization: Bearer $UNIEAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"kb_id": "kb_abc123",
"query": "What are the overtime pay rules?",
"mode": "hybrid",
"limit": 8,
"min_score": 0.18
}'| Field | Required | Current behavior |
|---|---|---|
kb_id | Yes | Knowledge base ID; access is checked for the API-key owner |
query | Yes | Non-empty search text |
mode | No | Defaults to hybrid; any other value is rejected |
limit | No | Defaults to 8 and is clamped to 1–50 |
min_score | No | Defaults to 0.18 and is clamped to 0–1 |
document_id | No | Restricts results to one document in the knowledge base |
The response reports mode: "hybrid", warnings, and result chunks with content, score, document and page identifiers, and available metadata. It does not contain detected_mode.
Remote MCP
The knowledge-base Remote MCP endpoint is:
POST {RUNTIME_BASE_URL}/v1/mcp/kb-searchAuthenticate with a platform API key in the Bearer header. The server supports the standard initialize, tools/list, and tools/call JSON-RPC methods and exposes kb_search.
{
"mcpServers": {
"unieai-kb": {
"url": "https://runtime.example.com/v1/mcp/kb-search",
"headers": {
"Authorization": "Bearer sk-your-api-key"
}
}
}
}The MCP tool performs Hybrid Search only. Its result limit defaults to 5 and is capped at 20; each returned chunk's text is capped for tool-context safety.
Customize Model agent retrieval
When a Customize Model has linked knowledge bases and its selected Agent Core exposes knowledge-base tools, the base model can call kb_search during a conversation.
The current agent flow can:
- Decide whether the uploaded documents are relevant to the question.
- Search all knowledge bases linked to the Customize Model with a focused query.
- Merge, sort, and deduplicate chunks across those knowledge bases.
- Refine the wording or use more specific terms and search again when the first result is insufficient.
- Use available source-follow-up tools when a promising result needs more surrounding document context.
- Compose an answer from the accumulated evidence.
This is agent-controlled iterative retrieval, not a request mode named auto. The model decides whether another tool call is useful; the server does not classify the query into HyDE or Multi-Query modes.
Agent tool schemas and source-follow-up behavior can differ by Agent Core version. Do not send mode, hyde, or reranking arguments to kb_search; use the tool schema advertised by the active core.
Result limits and thresholds
- The knowledge-base Search page and REST API use the
limitandmin_scoresupplied with that request. - Remote MCP defaults to 5 chunks and caps the limit at 20.
- A Customize Model uses the knowledge bases, Top K, and Min score saved in its Behavior → Agent Loop settings.
- Search-page parameters do not update Customize Model settings.
When multiple knowledge bases are linked, the final Top K is applied after candidates compete across the linked knowledge bases; it is not a separate quota for every knowledge base.
Failure and fallback behavior
| Situation | Current behavior |
|---|---|
Unsupported mode in REST | Returns a 400 error |
| API key cannot access the knowledge base | Returns an authorization or not-found error without leaking its content |
| One linked knowledge-base search fails | Other linked searches can still return results, with a warning recorded |
| Retrieval returns no chunks and fallback is allowed | Customize Model retrieval can use page-level content marked as fallback_pages |
| Agent's first query is too broad | The agent can issue another, narrower kb_search call |
| No relevant evidence is found | The agent should not claim that the knowledge base supports the answer |
Page fallback is a resilience path, not another search mode, and fallback scores must not be interpreted as Milvus Hybrid scores.
Practical tuning
- First verify that document parsing and indexing completed.
- Test a distinctive term known to exist in the source document.
- Lower Min score gradually when expected chunks are missing.
- Raise Min score or lower Limit when weak chunks overwhelm the useful context.
- Preserve exact identifiers in otherwise natural-language queries.
- For agent retrieval, make the Customize Model's System Prompt require citations or explicit uncertainty when evidence is missing.
- Review request logs and RAG metadata to confirm which query and sources actually produced the answer.