AgentOpsProjectNotFoundError
agentops.errors.AgentOpsProjectNotFoundError
Stack trace
Traceback (most recent call last):
File "main.py", line 42, in <module>
agent = AgentOpsClient(project_id="my-project")
File "/usr/local/lib/python3.9/site-packages/agentops/client.py", line 88, in __init__
raise AgentOpsProjectNotFoundError(f"Project '{project_id}' not found.")
agentops.errors.AgentOpsProjectNotFoundError: Project 'my-project' not found. Why it happens
This error occurs when the AgentOps client attempts to initialize or access a project that does not exist in your AgentOps account or the provided project identifier is incorrect. It can also happen if your API key lacks permissions to view the project or if the project was deleted.
Detection
Check for AgentOpsProjectNotFoundError exceptions during client initialization or API calls, and log the project ID and API key context to verify correctness before retrying.
Causes & fixes
Incorrect or misspelled project ID or name passed to the AgentOps client.
Verify and correct the project ID or name string to exactly match the project identifier in your AgentOps dashboard.
API key used does not have permission to access the specified project.
Ensure the API key has the necessary scopes or roles assigned in AgentOps to access the project.
The project was deleted or does not exist in the AgentOps account.
Confirm the project exists in your AgentOps account and recreate it if necessary.
Network or configuration issues causing the client to query the wrong environment or endpoint.
Check your AgentOps client configuration for correct environment variables and endpoint URLs.
Code: broken vs fixed
from agentops import AgentOpsClient
client = AgentOpsClient(project_id="my-project") # This line raises AgentOpsProjectNotFoundError
client.run_agent() import os
from agentops import AgentOpsClient
os.environ["AGENTOPS_API_KEY"] = os.environ.get("AGENTOPS_API_KEY", "your_api_key_here")
client = AgentOpsClient(project_id="correct-project-id") # Fixed project ID and set API key via env
client.run_agent()
print("Agent ran successfully.") Workaround
Catch AgentOpsProjectNotFoundError and prompt the user to verify the project ID or fallback to a default project if available.
Prevention
Implement validation of project IDs before client initialization and use environment-based configuration management to avoid hardcoding project identifiers.