# Knowledge

> Give the agent documents it can search, from Markdown or public URLs, with a vector store.

Source: https://sideagent.dev/docs/knowledge

Give the agent documents it can search, so it answers questions about your product and not only your API.

```ts
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. `maxSourceBytes` caps their size.
- URL sources refresh in the background after `ttlMs` (default one hour), or when you call `agent.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 `vectorStore` for large knowledge.
