SDKUpdated 2026-05-25
Agent Task API
Use SDK v5 to record agent events, retrieve task context, and create handoffs.
Applies to: @retaindb/sdk@5
The Agent Task API is the SDK entrypoint for Agent Memory Bus.
ts
const task = db.agent("planner").task("checkout-redesign");Record an event
Use events for decisions, observations, constraints, failures, tool results, and task updates.
ts
await task.event({
type: "decision",
summary: "Use hosted checkout for the first release.",
details: {
reason: "Fastest path with fewer PCI concerns."
},
salience: 0.9
});Get agent-ready context
ts
const context = await task.context({
query: "What should the builder know before implementation?",
topK: 8
});Create a handoff
ts
const handoff = await task.handoff({
toAgentId: "builder",
summary: "Implement the hosted checkout path.",
context: "Use Stripe Checkout. Keep custom payment UI out of v1."
});Resume a handoff
ts
const resumed = await db
.agent("builder")
.task("checkout-redesign")
.handoffResume(String(handoff.handoff_id), {
sessionId: "builder-session-001"
});Store durable task memory
ts
await task.remember("Checkout v1 should use hosted Stripe Checkout.", {
memoryType: "instruction"
});Next: Agent Memory Bus.
Was this page helpful?
Your feedback helps us prioritize docs improvements weekly.