Library
Knowledge
Give the agent documents it can search, from Markdown or public URLs, with a vector store.
Give the agent documents it can search, so it answers questions about your product and not only your API.
createAgent({
// ...
knowledge: {
embeddings: { model: "text-embedding-3-small" },
sources: [{ id: "guide", title: "Invoicing guide", content: markdownString }],
urls: ["https://docs.example.com/payment-terms", { url: "https://example.com/shipping", title: "Shipping" }],
},
vectorStore, // optional: pgvector, Vectorize, ...
});
The agent gets a search_knowledge tool. Answers show a Sources card, with links only for URLs you configured.
Behavior#
- Passages reach the model as labelled untrusted data and never reach the browser.
- URLs come only from config. They must be public http(s) and follow only same-host redirects.
maxSourceBytescaps their size. - URL sources refresh in the background after
ttlMs(default one hour), or when you callagent.knowledge.refresh(). - A source that fails to load is skipped with a warning, and shown in
doctor(). - The default store is in memory, so every start embeds all sources again. Pass a persistent
vectorStorefor large knowledge.