Skip to content

azd up should fail if the agent id doesn't exist #146

@qubitron

Description

@qubitron

When providing an agent id that doesn't exist in the project (using azd env set), the template deployment succeeds but then you discover upon chatting that it created a new agent.

Instead the deployment should fail so that you can fix it. I had to run locally to debug.

(.venv) C:\dev\agents-golden-path\src>python -m uvicorn "api.main:create_app" --factory --reload
INFO:     Will watch for changes in these directories: ['C:\\dev\\agents-golden-path\\src']
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [30908] using WatchFiles
2025-06-25 14:39:18,747 [INFO] azureaiapp: Tracing is not enabled
INFO:     Started server process [21080]
INFO:     Waiting for application startup.
2025-06-25 14:39:19,246 [INFO] azureaiapp: Created AIProjectClient
2025-06-25 14:39:25,532 [ERROR] azureaiapp: Error fetching agent: (None) No assistant found with id 'asst_Qd7wvcXRK8gVNo31404E4o7S'.
Code: None
Message: No assistant found with id 'asst_Qd7wvcXRK8gVNo31404E4o7S'.
Traceback (most recent call last):
  File "C:\dev\agents-golden-path\src\api\main.py", line 54, in lifespan
    agent = await ai_project.agents.get_agent(agent_id)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\dev\agents-golden-path\.venv\Lib\site-packages\azure\core\tracing\decorator_async.py", line 119, in wrapper_use_tracer
    return await func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\dev\agents-golden-path\.venv\Lib\site-packages\azure\ai\agents\aio\operations\_operations.py", line 4355, in get_agent
    map_error(status_code=response.status_code, response=response, error_map=error_map)
  File "C:\dev\agents-golden-path\.venv\Lib\site-packages\azure\core\exceptions.py", line 163, in map_error
    raise error
azure.core.exceptions.ResourceNotFoundError: (None) No assistant found with id 'asst_Qd7wvcXRK8gVNo31404E4o7S'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions