langchain-ai/deepagents · error

Error: Source agent '{source_agent}' not found or has no AGE

Error message

Error: Source agent '{source_agent}' not found or has no AGENTS.md
  Available agents: dcode agents list

What it means

reset_agent can re-seed an agent from another agent's AGENTS.md. When the named source agent's directory (or its AGENTS.md) does not exist, it prints this Rich-formatted error including a hint to run 'dcode agents list' and raises SystemExit(1) to terminate the CLI with a failure status.

Source

Thrown at libs/code/deepagents_code/agent.py:1370

        output_format: Output format — `'text'` (Rich) or `'json'`.

    Raises:
        SystemExit: If the source agent is not found.
    """
    agents_dir = user_deepagents_dir()
    agent_dir = agents_dir / agent_name

    if source_agent:
        source_dir = agents_dir / source_agent
        source_md = source_dir / "AGENTS.md"

        if not source_md.exists():
            console.print(
                f"[bold red]Error:[/bold red] Source agent '{source_agent}' not found "
                "or has no AGENTS.md\n"
                "  Available agents: dcode agents list"
            )
            raise SystemExit(1)

        source_content = source_md.read_text()
        action_desc = f"contents of agent '{source_agent}'"
    else:
        source_content = get_default_coding_instructions()
        action_desc = "default"

    if dry_run:
        if output_format == "json":
            from deepagents_code.output import write_json

            write_json(
                "reset",
                {
                    "agent": agent_name,
                    "reset_to": source_agent or "default",
                    "path": str(agent_dir),
                    "dry_run": True,

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Run the listed command to see valid names: dcode agents list, then retry with an exact name.
  2. If the agent should exist, recreate it (dcode agents create <name>) and ensure its AGENTS.md is present before resetting from it.
  3. If resetting to defaults was intended, omit the source-agent argument so reset_agent uses get_default_coding_instructions().

Example fix

// before
dcode agents reset --from clsud  # typo
// after
dcode agents list
dcode agents reset --from cloud
Defensive patterns

Strategy: validation

Validate before calling

import subprocess

listing = subprocess.run(
    ["dcode", "agents", "list"], capture_output=True, text=True, check=True
).stdout
if source_agent not in listing:
    raise SystemExit(f"Unknown source agent {source_agent!r}; run 'dcode agents list'")

Type guard

null

Try / catch

try:
    reset_agent(source_agent=name)
except SystemExit as exc:
    if exc.code != 0 and "not found or has no AGENTS.md" in captured_output:
        print(f"'{name}' is not a valid agent; run 'dcode agents list'")
    else:
        raise

Prevention

When it happens

Trigger: dcode agents reset --from <name> (reset_agent with source_agent=<name>) where <name> is not an existing agent directory or its AGENTS.md is missing — typo'd name, agent deleted, or agent created in a different checkout/namespace.

Common situations: Typo in the agent name; resetting from an agent that was removed with a partial delete (directory gone or AGENTS.md deleted); running in a different project where the source agent was never created; case-mismatched name.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/f16c8a06fc075fe7. Report an issue: GitHub.