An agent you write as code can now remember things, run long work, and act without a message. Upgrade
samva to 0.48.0 and @samva/cli to 0.42.0, then publish with samva agents publish. Nothing
breaks: a module that uses none of this publishes as before.
What you can do
- Keep state. Export a
Stateclass fromagent.ts.ctx.state.agentholds data shared across the agent's conversations, andctx.state.conversationholds data for one. Both keep their data when you publish new code. - Start a Workflow. Register a named Workflow in
defineAgentand start it from a tool or handler withctx.workflows.start. Repeating a start with the same idempotency key returns the same run, and a running Workflow keeps the module version that started it. - Run on a schedule. Add a handler to
schedulesunder a five-field cron expression in UTC. It runs from the current published version without a model turn.
schedules: {
"0 9 * * 1-5": async (ctx) => {
await ctx.state?.agent.call("increment", 1);
},
},
- Resume a conversation after a contact connects. Subscribe to
contact.connection_completedundereventTriggers. When a contact finishes the connection the agent asked for, only the conversation and agent that requested it wake. - Write email and WhatsApp templates from a brief. Pass
channel: "email"orchannel: "whatsapp"to suggestions andfrom-brief, or--channelonsamva templates suggestandfrom-brief. PassvariantOf(--variant-of) to make a template's other-channel version in one call, joined to the source's family. Template suggestions now includechannel, and theirslugcan be null, so handle that before you use it. - Add Samva to Vercel. In Integrations → Vercel, choose Add to Vercel to give your
projects a mailbox. Samva writes
SAMVA_API_KEYandSAMVA_MAILBOX_IDfor you, and every message that key sends waits for a person to approve it. API key responses include an optionalsourcenaming the Vercel install that created the key.
See keep state across calls for the full ctx.state contract
and add Samva to Vercel for the install steps.