Guides
Schedules and dreaming (memory consolidation) in camelRun v2
Wake camelRun v2 agents on intervals or cron expressions, and consolidate long-term memory into /workspace/MEMORY.md with dreaming.
camelRun v2 agents can wake themselves up on recurring schedules and run idle memory consolidation ("dreaming") via Durable Object alarms.
Schedules
Every agent can hold one or more schedules stored in its Durable Object SQLite state. When a schedule fires, camelRun starts a normal run on the agent with the schedule's prompt, so each wake-up sees the agent's full history and repository.
Create a schedule
Provide prompt plus either intervalSeconds or cronExpr (the alias cron is also accepted):
// Run every hour
const hourly = await agent.schedules.create({
intervalSeconds: 3600,
prompt: "Check open alerts and summarize anything new.",
});
// Run on a 5-field UTC cron schedule (weekdays at 09:00 UTC)
const daily = await agent.schedules.create({
cronExpr: "0 9 * * 1-5",
prompt: "Prepare the morning triage digest.",
});Over REST
# Create a schedule (requires tenant API key)
curl -s -X POST "https://run.camelai.com/v2/agents/ops-agent/schedules" \
-H "Authorization: Bearer $CAMELRUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"intervalSeconds": 3600,
"prompt": "Check error rates and update status.md."
}'
# List schedules
curl -s "https://run.camelai.com/v2/agents/ops-agent/schedules" \
-H "Authorization: Bearer $CAMELRUN_API_KEY"
# Delete a schedule (requires tenant API key)
curl -s -X DELETE "https://run.camelai.com/v2/agents/ops-agent/schedules/$SCHEDULE_ID" \
-H "Authorization: Bearer $CAMELRUN_API_KEY"Each schedule record returns:
{
"id": "sch_...",
"intervalSeconds": 3600,
"cronExpr": null,
"prompt": "Check error rates and update status.md.",
"nextDueAt": 1763762400000,
"enabled": true
}Creating and deleting schedules requires a tenant API key (cr_live_...). Listing schedules works with either a tenant API key or the agent's scoped token.
Scheduled runs wake up without an attached local WebSocket process. If a scheduled agent calls custom tools, configure them as HTTP webhook tools or remote MCP servers rather than local WebSocket tools.
Dreaming (memory consolidation)
Dreaming lets an agent synthesize recent conversation history into a durable /workspace/MEMORY.md file in its CamelFS repository while idle.
Automatic dreaming
Enable dreaming when upserting an agent:
const agent = await client.agents.upsert("research-assistant", {
instructions: "Check MEMORY.md for prior findings before starting new research.",
builtins: ["files", "web_search"],
dreaming: {
enabled: true,
idleSeconds: 3600, // consolidate after 1 hour of inactivity
},
});When the agent has been idle for idleSeconds, its Durable Object alarm triggers a memory consolidation pass, writes the updated /workspace/MEMORY.md commit to the agent's repository, and emits a dream_completed event (and agent.dream_completed webhook).
On-demand dreaming
Trigger consolidation immediately at any time with POST /v2/agents/:idOrKey/dream (agent.dream()):
const dream = await agent.dream();
console.log(dream);
// { ok: true, path: "MEMORY.md", commit: "<sha256>", summary: "..." }curl -s -X POST "https://run.camelai.com/v2/agents/research-assistant/dream" \
-H "Authorization: Bearer $CAMELRUN_API_KEY"