# Give agent modules state, Workflows, and schedules
URL: https://samva.dev/changelog/give-agent-modules-state-and-schedules
> samva 0.48 and CLI 0.42 let an agent written as code keep data between calls, start Workflows, and run on a cron schedule. Add Samva to Vercel from the dashboard.
- Published: 2026-11-19
- Tags: sdk, cli, dashboard

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 `State` class from `agent.ts`. `ctx.state.agent` holds data shared across
  the agent's conversations, and `ctx.state.conversation` holds data for one. Both keep their data
  when you publish new code.
- **Start a Workflow.** Register a named Workflow in `defineAgent` and start it from a tool or
  handler with `ctx.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 `schedules` under a five-field cron expression in UTC. It
  runs from the current published version without a model turn.

```ts title="agent.ts"
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_completed`
  under `eventTriggers`. 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"` or
  `channel: "whatsapp"` to suggestions and `from-brief`, or `--channel` on `samva templates suggest`
  and `from-brief`. Pass `variantOf` (`--variant-of`) to make a template's other-channel version in
  one call, joined to the source's family. Template suggestions now include `channel`, and their
  `slug` can 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_KEY` and `SAMVA_MAILBOX_ID` for you, and every message
  that key sends waits for a person to approve it. API key responses include an optional `source`
  naming the Vercel install that created the key.

See [keep state across calls](/docs/agents#keep-state-across-calls) for the full `ctx.state` contract
and [add Samva to Vercel](/docs/integrations/vercel) for the install steps.

## Links

- [Keep state across calls](/docs/agents#keep-state-across-calls)
- [Start a Workflow](/docs/agents#start-a-workflow)
- [Run on a schedule](/docs/agents#run-on-a-schedule)
- [Add Samva to Vercel](/docs/integrations/vercel)
- [samva 0.48.0 release notes](https://github.com/SamvaHQ/samva-typescript/releases/tag/samva%400.48.0)
- [@samva/cli 0.42.0 downloads](https://github.com/SamvaHQ/samva-cli/releases/tag/v0.42.0)

## Related

- [Build agents with the AI SDK, Chat SDK, and Eve](/changelog/build-agents-with-the-ai-sdk-chat-sdk-and-eve)
- [Write agents as code and publish them with the CLI](/changelog/write-agents-as-code)
- [All changelog entries](/changelog)
