Skip to main content
Dreaming is a scheduled review of an agent’s past work. In this example, a nightly schedule runs as each opted-in user, reads their recent traces, and updates their user memory.
Managed Deep Agents is in public beta on LangSmith Cloud and Bring Your Own Cloud (BYOC). Use Managed Deep Agents CLI and SDK v0.10 or later for BYOC.
This Python example requires managed-deepagents>=0.10.4, the matching mda CLI, and langsmith>=0.10.15. Self-hosted LangSmith must be v0.16 or later.
Mock private assistant chat alongside memory files showing an approved nightly dreaming schedule running at 03:00 UTC, updating /memories/user/AGENTS.md, and writing a skill proposal to dreaming-proposals.md. Mock private assistant chat alongside memory files showing an approved nightly dreaming schedule running at 03:00 UTC, updating /memories/user/AGENTS.md, and writing a skill proposal to dreaming-proposals.md.

Before you start

  • Configure identity so each person signs in as themselves. User memory and per-user trace lookups require a signed-in person.
  • Route each person’s traces to their own LangSmith tracing project.
  • Add DREAM_TRACE_PROJECTS to .env wrapped in single quotes so mda deploy preserves the JSON double quotes. Map MDA principal IDs to project IDs, and ensure the deployment’s LangSmith credentials have read access to those projects:
.env

Add personal memory

Declare user memory at the project root:
memory.py
Scheduled runs have no channel event, so select user memory in the agent factory when a run has no channel origin (such as scheduled runs and Studio). Omitting memory on channel runs keeps MDA’s default access rules, which mount user memory in Slack direct messages and keep it off in shared channels. Requiring an interrupt on schedule_dreaming prompts for approval before creating a schedule:
agent.py
MDA always mounts the signed-in person’s memory, so a prompt cannot read someone else’s.

Add the tools

recent_user_traces reads up to 25 of the current person’s traces from the last day. schedule_dreaming creates a nightly schedule that runs as that person. Install the model provider package (factory definitions do not auto-install provider packages):
tools/dreaming.py
Trace contents reach the model, so configure trace masking for anything it should not see.

Start dreaming

Deploy the agent, sign in, and ask it to schedule nightly dreaming from a direct conversation outside channels (such as LangSmith Studio or your own signed-in app, not Slack DMs). Approve the schedule_dreaming call. Each night at 03:00 UTC, the agent reviews your traces and updates /memories/user/AGENTS.md. Deployed instructions and skills are read-only at runtime. To apply an idea from /memories/user/dreaming-proposals.md, edit instructions.md or the skill in your project and redeploy. To stop dreaming, delete the schedule.

Extend the pattern

  • Review a week of traces instead of a day by changing the cron and the query window.
  • Test proposed instruction changes with evals before deploying.
  • Add a skill defining what is worth remembering so reviews stay consistent.

See also

  • Schedules: manage recurring user-owned runs.
  • Memory: configure durable memory and access policies.
  • Export traces: query and paginate trace data.