Modify agent code, add tools, or change configuration. Use when: (1) User says 'modify agent', 'add tool', 'change model', or 'edit agent.py', (2) Adding MCP servers to agent, (3) Changing agent instructions, (4) Understanding SDK patterns.
89
86%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
agent_server/agent.py - Agent logic, model selection, instructions, MCP servers
| File | Purpose |
|---|---|
agent_server/agent.py | Agent logic, model, instructions, MCP servers |
agent_server/start_server.py | FastAPI server + MLflow setup |
agent_server/evaluate_agent.py | Agent evaluation with MLflow scorers |
agent_server/utils.py | Databricks auth helpers, stream processing |
databricks.yml | Bundle config & resource permissions |
import mlflow
from databricks_openai import AsyncDatabricksOpenAI
from agents import set_default_openai_api, set_default_openai_client, Agent
from agents.tracing import set_trace_processors
# Set up async client (recommended for agent servers)
set_default_openai_client(AsyncDatabricksOpenAI())
set_default_openai_api("chat_completions")
# Use MLflow for tracing (disables SDK's built-in tracing)
set_trace_processors([])
mlflow.openai.autolog()from databricks_openai.agents import McpServer
# UC Functions
uc_server = McpServer(
url=f"{host}/api/2.0/mcp/functions/{catalog}/{schema}",
name="uc functions",
)
# Genie Space
genie_server = McpServer(
url=f"{host}/api/2.0/mcp/genie/{space_id}",
name="genie space",
)
# Vector Search
vector_server = McpServer(
url=f"{host}/api/2.0/mcp/vector-search/{catalog}/{schema}/{index}",
name="vector search",
)
# Add to agent
agent = Agent(
name="my agent",
instructions="You are a helpful agent.",
model="databricks-claude-3-7-sonnet",
mcp_servers=[uc_server, genie_server, vector_server],
)After adding MCP servers: Grant permissions in databricks.yml (see add-tools skill)
Available models (check workspace for current list):
databricks-claude-3-7-sonnetdatabricks-claude-3-5-sonnetdatabricks-meta-llama-3-3-70b-instructagent = Agent(
name="my agent",
model="databricks-claude-3-7-sonnet", # Change here
...
)Note: Some workspaces require granting the app access to the serving endpoint in databricks.yml. See the add-tools skill and examples/serving-endpoint.yaml.
agent = Agent(
name="my agent",
instructions="""You are a helpful data analyst assistant.
You have access to:
- Company sales data via Genie
- Product documentation via vector search
Always cite your sources when answering questions.""",
...
)from agents import Runner
# Non-streaming
messages = [{"role": "user", "content": "hi"}]
result = await Runner.run(agent, messages)
# Streaming
result = Runner.run_streamed(agent, input=messages)
async for event in result.stream_events():
# Process stream events
passConverting to Responses API format: Use process_agent_stream_events() from agent_server/utils.py to convert streaming output to Responses API compatible format:
from agent_server.utils import process_agent_stream_events
result = Runner.run_streamed(agent, input=messages)
async for event in process_agent_stream_events(result.stream_events()):
yield event # Yields ResponsesAgentStreamEvent objectsdfeb4ac
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.