Description
Running azd ai agent init (without flags) from inside a sample directory that contains agent.manifest.yaml fails with:
cannot copy agent files: target is inside the manifest directory
Repro Steps
-
Clone a sample repo containing agent manifests:
git clone https://github.com/azure-samples/foundry-samples
-
Navigate to a sample directory:
cd foundry-samples/samples/python/hosted-agents/agent-framework/responses/01-basic/
-
Run init:
azd ai agent init
-
When prompted 'An existing agent manifest was found. Use it?' select Yes
-
Enter an agent name (e.g. agent-framework-agent-basic-responses)
Expected Behavior
Init should complete successfully, creating a project subdirectory with the agent source files copied in.
Actual Behavior
Error: cannot copy agent files: target '...\01-basic\my-agent\src\my-agent' is inside the manifest directory '...\01-basic'
Root Cause
The auto-detect flow finds the manifest in CWD, then ensureProject creates a project subdirectory under CWD (since no azure.yaml exists). The subsequent copy step detects that the target directory is inside the manifest directory (source) and rejects to prevent infinite recursion. The code creates a state it then cannot resolve.
Workaround
Run from the parent directory with explicit -m flag:
cd .. && azd ai agent init -m ./01-basic/agent.manifest.yaml
Environment
- OS: Windows 11
- azd version: 0.1.37-preview (azure.ai.agents extension)
Description
Running
azd ai agent init(without flags) from inside a sample directory that containsagent.manifest.yamlfails with:Repro Steps
Clone a sample repo containing agent manifests:
git clone https://github.com/azure-samples/foundry-samplesNavigate to a sample directory:
cd foundry-samples/samples/python/hosted-agents/agent-framework/responses/01-basic/Run init:
azd ai agent initWhen prompted 'An existing agent manifest was found. Use it?' select Yes
Enter an agent name (e.g.
agent-framework-agent-basic-responses)Expected Behavior
Init should complete successfully, creating a project subdirectory with the agent source files copied in.
Actual Behavior
Error:
cannot copy agent files: target '...\01-basic\my-agent\src\my-agent' is inside the manifest directory '...\01-basic'Root Cause
The auto-detect flow finds the manifest in CWD, then
ensureProjectcreates a project subdirectory under CWD (since noazure.yamlexists). The subsequent copy step detects that the target directory is inside the manifest directory (source) and rejects to prevent infinite recursion. The code creates a state it then cannot resolve.Workaround
Run from the parent directory with explicit
-mflag:cd .. && azd ai agent init -m ./01-basic/agent.manifest.yamlEnvironment