
Company News
Jerod Santo Joins Socket as Head of Media
Allow myself to introduce... myself.
@agentskit/rag
Advanced tools
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, loadS3, loadGcs, loadDropbox, and loadOneDrive. Recipe.RagError (AK_RAG_LOAD_FAILED). Every remote request and body read has a finite timeout and byte limit by default; both are configurable through timeoutMs and maxResponseBytes. Optional signal aborts 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). loadUrl requires an HTTPS origin in allowedOrigins; it does not follow redirects. 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.rag.ingest embeds chunks serially and sends one vector-store batch per call. For large corpora, batch documents in the caller and persist progress between calls; the package does not silently add concurrency or an unbounded background queue.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 122 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.

Company News
Allow myself to introduce... myself.

Research
/Security News
A Twitch browser extension on Chrome and Firefox forwards users’ live OAuth session tokens through proxies controlled by a Russian bot service.

Security News
Anthropic found biased reasoning and recklessness drove Claude Mythos 5 to publish malware on PyPI and compromise a security vendor.