KnowledgeBase) is an agent’s external source of knowledge — a place to store static material such as product docs, FAQs, and articles. Attach it to an agent and VeADK automatically injects a retrieval tool, so the model can retrieve relevant snippets when needed. The model and instructions determine whether retrieval happens; mounting a knowledge base does not guarantee a search on every turn or replace source verification
Before running the local examples, install veadk-python[extensions] and complete embedding configuration. Agent and Runner examples also require model configuration
Unified entry point: KnowledgeBase
Regardless of the backend, everything goes through the unified veadk.knowledgebase.KnowledgeBase. It selects the storage backend through backend and exposes a consistent ingestion and retrieval interface. Ingestion supports three sources:
- From files:
kb.add_from_files([...]); - From a directory:
kb.add_from_directory("./docs"); - From text:
kb.add_from_text([...]).
Common parameters
The fields ofKnowledgeBase are common to all backends:
Vector backends (
local, opensearch, redis, milvus, and tos_vector) embed knowledge text locally and require the extensions extra plus an embedding model. viking, context_search, and openviking process resources server-side and do not need a local embedding model.Choosing a backend
Uselocal for development. Choose viking, context_search, or openviking for managed retrieval, or opensearch, redis, milvus, or tos_vector when you already operate a vector store.
Binding to an agent
Passknowledgebase to Agent and the agent automatically gains a load_knowledgebase tool, deciding on its own whether to search the knowledge base when answering.
Direct retrieval
Besides automatic retrieval at agent runtime, you can callsearch directly for semantic search, useful for debugging or custom RAG. A top_k of 0 uses the value set at construction.
Ingestion and access boundaries
Ingestion methods return a Boolean; success from a managed backend can mean submission rather than completed parsing.search() returns a list of KnowledgebaseEntry objects with text in entry.content, or an empty list for no match. Repeated ingestion does not guarantee deduplication; track processed documents in production
A knowledge base is generally shared at application scope and does not automatically filter access by session user_id. Establish which documents may be accessed before mounting it on an agent. Directory recursion, media extraction, and filtering options vary by backend. Call kb.close() when finished to release backend connections
Knowledge base profiles
enable_profile lets the agent consult knowledge base profiles before forming search queries. It is disabled by default. Generate profiles with await kb.generate_profiles(files=[...]) before enabling it and retain the output files in the default directory. Profile generation does not replace knowledge ingestion.
Profile generation currently uses
deepseek-v3-2-251201. Confirm that your configured model service can access it; changing the main agent model does not replace the profile generation model. If that model is unavailable in BytePlus or another environment, keep profiles disabled; ordinary knowledge retrieval remains available.
The example prepares a file, ingests it, generates profiles, checks that the output is nonempty, and enables the feature. The method writes files without returning a profile list. Retrieval reads the index-specific profile directory under the current working directory; move custom-path output there before using it.
query_with_user_profile is a separate setting that adds a Viking long-term-memory user profile to query instructions. The same agent must have long-term memory that can supply a user profile; these profiles are separate from knowledge base profile files.