> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentium.in/llms.txt
> Use this file to discover all available pages before exploring further.

# 4. Answer from policies

> Retrieve evidence from a knowledge base and include source IDs.

[Support assistant tutorial](/learn/support-assistant)

This checkpoint focuses on retrieval. `InMemoryVectorStore` takes an embedding provider, and `KnowledgeBase.asTool()` exposes search to the model. Indexing and searching can make embedding requests in addition to the Agent's model calls.

## Complete checkpoint

```typescript support.ts theme={null}
import {
  Agent, InMemoryVectorStore, KnowledgeBase, OpenAIEmbedding, openai,
} from "@agentium/core";

const knowledge = new KnowledgeBase({
  name: "Store policies",
  vectorStore: new InMemoryVectorStore(new OpenAIEmbedding()),
});
const agent = new Agent({
  name: "support",
  model: openai(process.env.OPENAI_MODEL ?? "gpt-6.1-sol"),
  instructions: "Search store policies before answering. Cite document IDs. If evidence is missing, say so.",
  tools: [knowledge.asTool({
    toolName: "search_policies",
    topK: 2,
    formatResults: (results) => results.map((item) => `[${item.id}] ${item.content}`).join("\n\n"),
  })],
});

try {
  await knowledge.addDocuments([
    { id: "returns", content: "Unopened items can be returned within 30 days of delivery. Refunds require staff approval." },
    { id: "shipping", content: "Standard shipping takes 3–5 business days. Order tracking provides the delivery estimate." },
  ]);
  const result = await agent.run("Can I return an unopened item after 14 days?");
  if (result.status !== "completed") throw new Error(`Run ended: ${result.status}`);
  console.log(result.text);
} finally {
  try { await agent.close(); } finally { await knowledge.close(); }
}
```

## Run it

```bash theme={null}
npx tsx support.ts
```

## Verify the result

The answer should say that an unopened item at 14 days is within the 30-day return window and cite `[returns]`. It should keep the staff-approval condition.

The source ID helps you inspect where an answer came from; a citation alone does not prove that the answer is supported. Evaluate both retrieval and the final response.

**Try an unsupported question:** ask about international customs fees. The supplied documents contain no answer. Check that the assistant acknowledges the missing evidence.

This catalog is rebuilt on each run. Before adding production documents, choose a persistent vector store, bind retrieval to tenant visibility, and plan document updates/deletions. See [knowledge guides](/knowledge/overview).

<Card title="Require a human decision" icon="arrow-right" href="/learn/approval">Continue to the next chapter.</Card>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.