> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-harris-1786029617-6b0a55e.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Build a scheduled research agent

> Build a Managed Deep Agent with a tool, durable memory, and a daily schedule, then deploy it.

This tutorial builds a research assistant one capability at a time. Complete the [quickstart](/langsmith/managed-deep-agents-quickstart) first to scaffold a project, add API keys, and run `mda dev` locally. Then add a search tool, use durable memory, run the agent on a daily schedule, and deploy it to LangSmith.

For a complete project that combines common features, see the [example project](/langsmith/managed-deep-agents-examples).

<Note>
  Managed Deep Agents is in **public [beta](/langsmith/release-stages)** and available on [LangSmith Cloud](/langsmith/cloud) in the US region only.
</Note>

## Build the agent

<Steps>
  <Step title="Write the instructions" id="instructions">
    Replace `instructions.md` with the research assistant's behavior. The instructions reference the tool you add next and the shared durable memory you explicitly enable later in this tutorial:

    ```markdown instructions.md theme={null}
    # Research assistant

    You are a careful research assistant. Find sources, keep notes, and return
    concise answers with citations.

    ## Behavior

    - Use the `web_search` tool to find sources instead of guessing.
    - Cite the sources you used.

    ## Memory

    - Record reusable research procedures and project knowledge that can improve future work.
    - For release research, check the project's official changelog before secondary sources.
    - Never store personal data or secrets in memory.
    ```
  </Step>

  <Step title="Add a search tool" id="add-tool">
    Create a `tools/` module with a search tool, then import it into the agent entry. This example returns a placeholder result, so it runs without an external API. Replace the body with a call to your search provider.

    <CodeGroup>
      ```python tools/search.py theme={null}
      from langchain.tools import tool


      @tool(parse_docstring=True)
      def web_search(query: str) -> str:
          """Search the web for a query and return result snippets.

          Args:
              query: The search query.
          """
          # Replace this stub with a call to your search provider.
          return f"Top results for '{query}': ..."
      ```

      ```ts tools/search.ts theme={null}
      import { tool } from "langchain";
      import { z } from "zod";

      export const webSearch = tool(
        async ({ query }) => {
          // Replace this stub with a call to your search provider.
          return `Top results for '${query}': ...`;
        },
        {
          name: "web_search",
          description: "Search the web for a query and return result snippets.",
          schema: z.object({
            query: z.string().describe("The search query."),
          }),
        },
      );
      ```
    </CodeGroup>

    Import the tool into the agent entry and pass it to the definition:

    <CodeGroup>
      ```python agent.py theme={null}
      from managed_deepagents import define_deep_agent

      from tools.search import web_search

      agent = define_deep_agent(
          name="research-assistant",
          model="openai:gpt-5.5",
          tools=[web_search],
      )
      ```

      ```ts agent.ts theme={null}
      import { defineDeepAgent } from "managed-deepagents";

      import { webSearch } from "./tools/search";

      export const agent = defineDeepAgent({
        name: "research-assistant",
        model: "openai:gpt-5.5",
        tools: [webSearch],
      });
      ```
    </CodeGroup>

    For more on authored tools, see [Custom tools](/langsmith/managed-deep-agents-tools).
  </Step>

  <Step title="Run the agent locally" id="run-local">
    Install dependencies and start the local dev server:

    <CodeGroup>
      ```bash uv theme={null}
      uv sync
      mda dev .
      ```

      ```bash npm theme={null}
      npm install
      mda dev .
      ```
    </CodeGroup>

    `mda dev` opens the agent in LangSmith Studio. Send a question and confirm the agent calls `web_search` and answers with the returned snippets.
  </Step>

  <Step title="Enable and use durable memory" id="memory">
    Durable memory is opt-in. Before asking the agent to remember anything, add a memory declaration at the project root:

    <CodeGroup>
      ```python memory.py theme={null}
      from managed_deepagents import define_memory

      memory = define_memory(scope="agent")
      ```

      ```ts memory.ts theme={null}
      import { defineMemory } from "managed-deepagents";

      export const memory = defineMemory({ scope: "agent" });
      ```
    </CodeGroup>

    Memory is shared across the deployment and visible to all callers, so do not store personal data or secrets.

    Restart `mda dev` so it discovers the new file. In one thread, ask the agent to research a release and to record a reusable project rule, such as "For release research, check the official changelog before secondary sources." Then create a **new thread** in Studio and ask how it will research the next release. Confirm that it applies the shared rule even though the new thread has no conversation history.

    See [Memory](/langsmith/managed-deep-agents-memory) for details.
  </Step>

  <Step title="Schedule a daily digest" id="schedule">
    Add a `schedules/` module so the agent runs on a cron cadence without a user message. This schedule runs every weekday at 8am Pacific:

    <CodeGroup>
      ```python schedules/daily_digest.py theme={null}
      from managed_deepagents import define_schedule

      schedule = define_schedule(
          cron="0 8 * * 1-5",
          timezone="America/Los_Angeles",
          prompt="Summarize what you learned yesterday and list open questions.",
      )
      ```

      ```ts schedules/daily-digest.ts theme={null}
      import { defineSchedule } from "managed-deepagents";

      export const schedule = defineSchedule({
        cron: "0 8 * * 1-5",
        timezone: "America/Los_Angeles",
        prompt: "Summarize what you learned yesterday and list open questions.",
      });
      ```
    </CodeGroup>

    `mda deploy` reconciles this schedule into a LangSmith cron job after the deployment is live. For thread behavior and constraints, see [Schedules](/langsmith/managed-deep-agents-schedules).
  </Step>

  <Step title="Deploy the agent" id="deploy">
    Deploy the project to LangSmith:

    ```bash theme={null}
    mda deploy .
    ```

    On success, the CLI prints the deployment dashboard URL. The deploy syncs the instructions to Context Hub, uploads the compiled project, and reconciles the daily schedule. For deploy flags and troubleshooting, see [Deploy an agent](/langsmith/managed-deep-agents-deploy) and the [CLI reference](/langsmith/managed-deep-agents-cli#deploy-projects).
  </Step>

  <Step title="Inspect the run" id="inspect">
    Open the printed URL in LangSmith to inspect build status and revisions. Open traces to inspect the agent's inputs, model calls, `web_search` calls, memory reads and writes, and final responses.
  </Step>
</Steps>

## Next steps

<CardGroup cols={2}>
  <Card title="Custom middleware" icon="code" href="/langsmith/managed-deep-agents-middleware">
    Add logging, retries, limits, and guardrails around model and tool calls.
  </Card>

  <Card title="Identity" icon="fingerprint" href="/langsmith/managed-deep-agents-identity">
    Authenticate callers and use verified identity in tools and middleware.
  </Card>

  <Card title="Memory" icon="brain" href="/langsmith/managed-deep-agents-memory">
    Persist shared procedural and project knowledge across threads.
  </Card>

  <Card title="Evals" icon="flask" href="/langsmith/managed-deep-agents-evals">
    Compile a Harbor handoff and run Harbor-style tasks.
  </Card>

  <Card title="Sandboxes" icon="box" href="/langsmith/managed-deep-agents-sandboxes">
    Configure isolated filesystem and shell access for agent work.
  </Card>

  <Card title="Example project" icon="apps" href="/langsmith/managed-deep-agents-examples">
    See a complete project that combines common features.
  </Card>
</CardGroup>

***

<div className="source-links">
  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>

  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/langsmith/managed-deep-agents-tutorial.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>
</div>
