{"record":{"id":"f16c8a06fc075fe7","repo":"langchain-ai/deepagents","slug":"error-source-agent-source-agent-not-found-or","errorCode":null,"errorMessage":"Error: Source agent '{source_agent}' not found or has no AGENTS.md\n  Available agents: dcode agents list","messagePattern":"Error: Source agent '(.+?)' not found or has no AGENTS\\.md\n  Available agents: dcode agents list","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/agent.py","lineNumber":1370,"sourceCode":"        output_format: Output format — `'text'` (Rich) or `'json'`.\n\n    Raises:\n        SystemExit: If the source agent is not found.\n    \"\"\"\n    agents_dir = user_deepagents_dir()\n    agent_dir = agents_dir / agent_name\n\n    if source_agent:\n        source_dir = agents_dir / source_agent\n        source_md = source_dir / \"AGENTS.md\"\n\n        if not source_md.exists():\n            console.print(\n                f\"[bold red]Error:[/bold red] Source agent '{source_agent}' not found \"\n                \"or has no AGENTS.md\\n\"\n                \"  Available agents: dcode agents list\"\n            )\n            raise SystemExit(1)\n\n        source_content = source_md.read_text()\n        action_desc = f\"contents of agent '{source_agent}'\"\n    else:\n        source_content = get_default_coding_instructions()\n        action_desc = \"default\"\n\n    if dry_run:\n        if output_format == \"json\":\n            from deepagents_code.output import write_json\n\n            write_json(\n                \"reset\",\n                {\n                    \"agent\": agent_name,\n                    \"reset_to\": source_agent or \"default\",\n                    \"path\": str(agent_dir),\n                    \"dry_run\": True,","sourceCodeStart":1352,"sourceCodeEnd":1388,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/agent.py#L1352-L1388","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run the listed command to see valid names: dcode agents list, then retry with an exact name.","If the agent should exist, recreate it (dcode agents create <name>) and ensure its AGENTS.md is present before resetting from it.","If resetting to defaults was intended, omit the source-agent argument so reset_agent uses get_default_coding_instructions()."],"exampleFix":"// before\ndcode agents reset --from clsud  # typo\n// after\ndcode agents list\ndcode agents reset --from cloud","handlingStrategy":"validation","validationCode":"import subprocess\n\nlisting = subprocess.run(\n    [\"dcode\", \"agents\", \"list\"], capture_output=True, text=True, check=True\n).stdout\nif source_agent not in listing:\n    raise SystemExit(f\"Unknown source agent {source_agent!r}; run 'dcode agents list'\")","typeGuard":"null","tryCatchPattern":"try:\n    reset_agent(source_agent=name)\nexcept SystemExit as exc:\n    if exc.code != 0 and \"not found or has no AGENTS.md\" in captured_output:\n        print(f\"'{name}' is not a valid agent; run 'dcode agents list'\")\n    else:\n        raise","preventionTips":["Run 'dcode agents list' before resetting to confirm the exact source-agent name.","Check for the directory and its AGENTS.md before invoking: from pathlib import Path; assert Path('.dcode/agents', name, 'AGENTS.md').exists() (adjust to your agents root).","Remember the check is name-exact: watch for typos and case mismatches.","If you want defaults, call reset_agent without a source agent instead of naming a nonexistent one."],"tags":["cli","agents","file-not-found","exit-code"],"backgroundTag":"resource-not-found","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}