Agent Task API
Record agent events, retrieve task context, and create handoffs with the SDK.
The Agent Task API is the SDK entrypoint for shared agent memory.
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 API or MCP Setup.
Was this page useful?
Your feedback helps us make the product easier to ship with.