vectorSearch() with your actual vector DB client.
What you’ll learn
- Using
plainTool()for tools without dependency injection - Passing retrieved context to the model via tool results
- Structuring a RAG pipeline with Vibes
Prerequisites
ANTHROPIC_API_KEYset in your environment- Vibes installed (
deno add jsr:@vibesjs/sdk npm:@ai-sdk/anthropic npm:zod)
Complete example
Run it
How it works
plainTool(): A simpler variant of tool() - no RunContext, the execute function receives args directly. Use plainTool() when your tool doesn’t need access to deps. Use tool() (or tool<TDeps>()) when it does.
Tool result as context: When the agent calls search_docs, Vibes executes vectorSearch() and passes the result back to the model as a tool response. The model uses this retrieved context to form its answer - no prompt engineering needed.
Plugging in a real vector DB: Replace the vectorSearch() function body with your vector DB client. The Vibes pattern is identical regardless of the underlying store. For dependency-injected DB clients (e.g., a shared connection pool), use tool<Deps>() and access the client via ctx.deps.
The retrieval quality in this example is intentionally minimal (keyword overlap). A real RAG system uses embedding-based semantic search. The Vibes pattern - tool calls retriever, model uses results - is identical.
Next steps
- Tools concept page -
plainTool,tool,fromSchema - Dependencies concept page - for injecting DB clients into tools