Skip to content

[azure.ai.agents] azd ai agent init fails with 'cannot copy agent files: target is inside the manifest directory' when run from sample directory #8523

@v1212

Description

@v1212

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

  1. Clone a sample repo containing agent manifests:
    git clone https://github.com/azure-samples/foundry-samples

  2. Navigate to a sample directory:
    cd foundry-samples/samples/python/hosted-agents/agent-framework/responses/01-basic/

  3. Run init:
    azd ai agent init

  4. When prompted 'An existing agent manifest was found. Use it?' select Yes

  5. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions