I’m facing an issue where my Azure AI Agent Service seems to keep references to deleted connections even when they’re not being used anywhere.
When I check for existing agents using agent_service.agents.get_all_agents(), it returns empty results as expected:
{'object': 'list', 'data': [], 'first_id': None, 'last_id': None, 'has_more': False}
But after removing an Azure AI search connection with this command:
az ml connection delete -n search-connection-demo --resource-group demo-rg --workspace-name demo-workspace-01
The agent_service.agents.get_all_agents() method starts failing with a JSON decode error:
DecodeError: JSON is invalid: Expecting value: line 1 column 1 (char 0)
Content: Exception Type: ServiceInvocationException
Message: Service invocation failed!
Status Code: 404 NotFound
Error Code: UserError/NotFoundError
Reason Phrase: Connection search-connection-demo can't be found in this workspace
The strange part is that I don’t have any agents configured, so there shouldn’t be any references to this connection. Even when I create a new connection with a different name, operations like get_all_agents() or list_files() continue to fail because the service is still looking for the old connection name.
Right now my only solution is to avoid deleting the original connection entirely. Has anyone encountered this behavior before? Is there a way to clear these phantom references?