Agents can have knowledge bases linked to them in the Workbench. From code, you can attach more, load theDocumentation Index
Fetch the complete documentation index at: https://docs.xpander.ai/llms.txt
Use this file to discover all available pages before exploring further.
KnowledgeBase objects, or build a retriever callable for use as a framework retriever.
aget_knowledge_bases
Load every KnowledgeBase linked to the agent, in parallel.
Returns list[KnowledgeBase]
A list of full KnowledgeBase objects. See KnowledgeBase for the methods you can call on each.
Sync version
attach_knowledge_base
Link a knowledge base to the agent on the in-memory instance. Pass either a KnowledgeBase object or a knowledge-base ID.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
knowledge_base | KnowledgeBase | No | A KnowledgeBase instance. |
knowledge_base_id | str | No | Knowledge-base ID. |
knowledge_base.id is used.
attach_knowledge_base only updates the agent in memory. To persist the link, save the agent through the platform (e.g. via the API or the Workbench UI). The runtime instance will use the link for the current session, but it won’t survive a re-load.knowledge_bases_retriever
Returns a search(query, agent=None, num_documents=5) callable that searches every linked KB and returns top-N results sorted by score. This is the form Agno expects as a custom retriever.
Returned callable signature
| Parameter | Type | Default | Description |
|---|---|---|---|
query | str | – | Search query. |
agent | Any | None | Ignored. Present for compatibility with framework retriever signatures. |
num_documents | int | 5 | Top-K to return. If 0 is passed, defaults to 10. |
KnowledgeBaseSearchResult.model_dump():
[] if the search fails: useful for embedding into framework pipelines that shouldn’t crash on retrieval errors.
Patterns
Wire as the Agno knowledge
Backend.aget_args already wires the retriever for you: you don’t usually need to call knowledge_bases_retriever() directly. Use it only when bypassing the Backend dispatcher.
Add a KB on the fly
attach_knowledge_base, agent.aget_knowledge_bases() includes the new KB in the list.
