
Security News
White House Authorizes Private Companies to Conduct Offensive Cyber Operations
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.
@agentskit/rag
Advanced tools
Profile: major-package
Plug-and-play retrieval-augmented generation: chunk documents, embed them, and retrieve the right context at query time.
Tags: ai · agents · llm · agentskit · rag · retrieval · vector-search · embeddings · ai-agents · semantic-search · knowledge-base
packages/rag/.@agentskit/rag is the retrieval layer: load documents, chunk them, embed them, rerank results, and feed precise context back to agents.
Docs: package guide · agent handoff
EmbedFn and any VectorMemory from @agentskit/adapters and @agentskit/memory; swap either layer without touching RAG logiccreateRAG() returns a Retriever you pass to @agentskit/runtime or useChat so context is injected automaticallychunkSize, chunkOverlap, or a custom split function — three knobs that cover 95% of use casesnpm install @agentskit/rag @agentskit/memory @agentskit/adapters
The file-backed example also needs the optional vectra peer. Add
vectra to the install command when using fileVectorMemory; the runtime
integration example additionally needs @agentskit/runtime.
import { createRAG } from '@agentskit/rag'
import { openaiEmbedder } from '@agentskit/adapters'
import { fileVectorMemory } from '@agentskit/memory'
const rag = createRAG({
embed: openaiEmbedder({ apiKey: process.env.OPENAI_API_KEY! }),
store: fileVectorMemory({ path: './vectors' }),
})
await rag.ingest([
{ id: 'doc-1', content: 'AgentsKit is a JavaScript agent toolkit...' },
])
const docs = await rag.search('How does AgentsKit work?', { topK: 5 })
console.log(docs)
Pass the RAG instance as retriever so the runtime injects retrieved context into the task:
import { createRuntime } from '@agentskit/runtime'
import { openai } from '@agentskit/adapters'
const runtime = createRuntime({
adapter: openai({ apiKey: process.env.OPENAI_API_KEY!, model: 'gpt-4o' }),
retriever: rag,
})
const result = await runtime.run('Explain the AgentsKit architecture based on ingested docs')
console.log(result.content)
You can also call rag.retrieve({ query, messages }) to satisfy the core Retriever contract (for example from a custom controller).
createRAG({ embed, store }) — single entry point for ingest + retrieve.rag.ingest(docs) — chunk, embed, and store documents.rag.search(query, { topK }) — semantic similarity search.rag.retrieve({ query, messages }) — Retriever contract v1 for runtime/controller injection.chunkSize, chunkOverlap, custom split.EmbedFn and any VectorMemory.createRerankedRetriever (Voyage, Jina, custom RerankFn, BM25 default), createHybridRetriever (vector + BM25 blend), standalone bm25Score. Recipe.loadUrl, loadGitHubFile, loadGitHubTree, loadNotionPage, loadConfluencePage, loadGoogleDriveFile, loadPdf (BYO parser). Recipe.RagError (AK_RAG_LOAD_FAILED). Optional signal aborts (including mid-body reads) are never swallowed as a per-object skip. Tree/list loaders may return partial success when at least one eligible download succeeded; if every attempted eligible download failed, they throw. Missing/invalid S3 object bodies count as failed downloads. Pagination that reports more data without a new cursor/token throws (no silent truncation). loadNotionPage follows Notion has_more / next_cursor with start_cursor until complete (preserving block order; incomplete or repeated cursors throw). Non-positive / non-finite maxFiles yields [].-Infinity). Malformed Voyage/Jina/custom reranker output throws AK_RAG_RERANK_FAILED. Optional signal on voyageReranker / jinaReranker is forwarded to fetch; request/body aborts remain AK_RAG_RERANK_FAILED. bm25Score sanitizes invalid k1/b to documented defaults and always emits finite scores. Hybrid relative weights are normalized to a finite pair that sums to 1 (both zero → 0.5/0.5).chunkSize / chunkOverlap / topK values are sanitized so chunking always terminates and search never sends non-finite limits to the store.Node consumers may install @aws-sdk/client-s3 and let loadS3 resolve it lazily. Browser, Expo/Metro, and React Native bundles keep that peer out of the universal entry; pass the command constructors explicitly when invoking the loader:
import { GetObjectCommand, ListObjectsV2Command, S3Client } from '@aws-sdk/client-s3'
import { loadS3 } from '@agentskit/rag'
await loadS3({
client: new S3Client({}),
bucket: 'knowledge',
commands: { GetObjectCommand, ListObjectsV2Command },
})
| Package | Role |
|---|---|
| @agentskit/core | Retriever, VectorMemory, types |
| @agentskit/memory | Vector backends (fileVectorMemory, etc.) |
| @agentskit/adapters | openaiEmbedder and other embedders |
| @agentskit/runtime | retriever integration for agents |
| @agentskit/react | useChat + chat UI with the same core types |
MIT — see LICENSE.
@agentskit/ragSee CONTRIBUTING.md and the monorepo LICENSE.
FAQs
Plug-and-play retrieval-augmented generation for AgentsKit.
The npm package @agentskit/rag receives a total of 753 weekly downloads. As such, @agentskit/rag popularity was classified as not popular.
We found that @agentskit/rag demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.

Research
/Security News
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.