Hello @brahaman ,
The notice you're seeing is exactly what's causing the authentication issue when your agent is deployed. When running in a notebook, the `DatabricksVectorSearch` class automatically uses your notebook authentication token (which works fine for development), but this authentication method fails when the agent is served because the deployed endpoint doesn't have access to your personal credentials.
The Solution: Use Automatic Authentication Passthrough
The recommended approach for production deployment is to use Databricks' automatic authentication passthrough feature. This eliminates authentication issues by automatically managing credentials for your agent.
Here's how to fix your code:
1. Update your agent logging to declare the Vector Search index as a resource:
```python
import mlflow
from mlflow.models.resources import DatabricksVectorSearchIndex, DatabricksServingEndpoint
# When you log your model, add the resources parameter
with mlflow.start_run():
logged_agent_info = mlflow.pyfunc.log_model(
python_model="your_agent.py", # Your agent file
artifact_path="agent",
input_example=input_example,
example_no_conversion=True,
resources=[
DatabricksVectorSearchIndex(
index_name="dbw_genai_sbx_databricks.unstructured.pdf_docs_chunked_index"
),
DatabricksServingEndpoint(
endpoint_name="databricks-meta-llama-3-3-70b-instruct"
)
]
)
```
2. You don't need to modify your tool initialization code.
When the agent is deployed with resources declared, Databricks automatically provisions a service principal with the necessary permissions and handles all authentication.
How It Works
When you declare resources during logging, Databricks:
1. Verifies you (the deployer) have access to those resources
2. Automatically creates a service principal for your agent with least-privilege access
3. Manages short-lived OAuth tokens that are automatically rotated
This approach provides better security than manual authentication and eliminates the performance overhead mentioned in the notice (up to 100ms per query).
Requirements
- Ensure you're using MLflow 2.13.1 or above for Vector Search automatic authentication
- You must have `Can Use` permission on the Vector Search index when deploying
Hope this helps, Louis.