What Adapters Do
Adapters wire the before/after lifecycle into your agent framework automatically. They:
- Register lifecycle hooks with your framework's event system
- Inject belief context into system prompts before each turn
- Route agent output and tool results to
afterafter each turn - Handle capture modes (what to extract beliefs from)
The core SDK already extracts beliefs automatically from output and toolCalls. Adapters handle the framework lifecycle so you do not need to call before/after yourself.
When to Use an Adapter
Use an adapter when one exists for your framework. It handles lifecycle wiring with minimal configuration.
Use the core SDK directly when:
- Your framework is not supported
- You are building a custom agent loop
- You want to submit beliefs from non-agent sources (user input, external data)
- You need fine-grained control over when
before/afterare called
Available Adapters
| Adapter | Import | Framework | Status |
|---|---|---|---|
| Claude Agent SDK | beliefs/claude-agent-sdk | Anthropic Claude Agent SDK | Available |
| Vercel AI | beliefs/vercel-ai | Vercel AI SDK | Available |
| React | @beliefs/react | React | Coming soon |
| DevTools | @beliefs/devtools | Browser | Coming soon |
Building a Custom Adapter
Adapters are thin wrappers around the core SDK. The minimal interface:
1function myAdapter(beliefs: Beliefs, options?: AdapterOptions) {
2 return {
3 async before(input: string) {
4 const context = await beliefs.before(input)
5 return context
6 },
7
8 async after(output: string) {
9 return beliefs.after(output)
10 },
11 }
12}The core SDK handles belief extraction from output. Your adapter's job is lifecycle wiring — connecting your framework's events to before/after.