This directory contains all agent logic in a modular structure.
This is the single source of truth for agent code, used by:
config.py + .env)dev_config.yaml)prod_config.yaml)All three workflows use the same code from this directory!
src/multi_agent/
โโโ __init__.py # Package exports
โโโ main.py # CLI entry point (local dev)
โโโ agents/ # Agent implementations
โ โโโ __init__.py
โ โโโ clarification.py # Clarification node + helpers
โ โโโ planning.py # Planning node + helpers
โ โโโ planning_agent.py # PlanningAgent class
โ โโโ sql_synthesis.py # SQL synthesis nodes
โ โโโ sql_synthesis_agents.py # SQL synthesis agent classes
โ โโโ sql_execution.py # SQL execution node
โ โโโ sql_execution_agent.py # SQLExecutionAgent class
โ โโโ summarize.py # Summarization node
โ โโโ summarize_agent.py # ResultSummarizeAgent class
โโโ core/ # Core infrastructure
โ โโโ __init__.py
โ โโโ config.py # Configuration management
โ โโโ state.py # State TypedDicts and helpers
โ โโโ graph.py # LangGraph workflow
โโโ tools/ # Agent tools
โ โโโ __init__.py
โ โโโ uc_functions.py # Unity Catalog functions
โโโ utils/ # Utilities
โโโ __init__.py
โโโ conversation.py # Conversation management
โโโ intent_detection_service.py # Intent detection
agents/: agents/my_new_agent.py"""My new agent implementation."""
from typing import Dict, Any
from ..core.state import AgentState
def my_new_agent_node(state: AgentState) -> Dict[str, Any]:
"""
My new agent node function.
Args:
state: Current agent state
Returns:
State updates
"""
# Your agent logic here
return {
"messages": [{"role": "assistant", "content": "response"}],
"next_agent": "summarize"
}
core/graph.py):from ..agents.my_new_agent import my_new_agent_node
# In create_super_agent_hybrid():
workflow.add_node("my_new_agent", my_new_agent_node)
workflow.add_edge("some_node", "my_new_agent")
tests/unit/test_my_new_agent.py):import pytest
from src.multi_agent.agents.my_new_agent import my_new_agent_node
def test_my_new_agent():
state = {"messages": []}
result = my_new_agent_node(state)
assert "messages" in result
pytest tests/unit/test_my_new_agent.py -v
python -m src.multi_agent.main --query "test new agent"
agents/supervisor.py)pytest tests/unit/test_supervisor.py -vpytest tests/python -m src.multi_agent.main --query "test"notebooks/test_agent_databricks.pynotebooks/deploy_agent.pyThe codebase has two patterns:
Agent Classes (e.g., PlanningAgent):
Agent Node Functions (e.g., planning_node):
Pattern:
# Agent class
class PlanningAgent:
def __init__(self, llm, vector_search_index):
self.llm = llm
self.vector_search_index = vector_search_index
def plan(self, query):
# Complex planning logic
pass
# Node function (used by graph)
def planning_node(state: AgentState) -> dict:
# Extract context
query = state["current_turn"]["query"]
# Get or create agent instance
agent = get_cached_planning_agent()
# Call agent
result = agent.plan(query)
# Return state updates
return {"plan": result}
Follow these guidelines:
# Format code
black src/multi_agent/
isort src/multi_agent/
# Lint
flake8 src/multi_agent/
# Type check
mypy src/multi_agent/
Standards:
# Uses config.py + .env
python -m src.multi_agent.main --query "test"
Configuration: .env file
Purpose: Fast iteration, unit testing
# Uses dev_config.yaml
# In notebooks/test_agent_databricks.py
import sys
sys.path.insert(0, "../src")
from multi_agent.core.graph import create_agent_graph
Configuration: dev_config.yaml
Purpose: Test with real Databricks services
# Uses prod_config.yaml
# In notebooks/deploy_agent.py
mlflow.pyfunc.log_model(
python_model="./agent.py",
code_paths=["../src/multi_agent"], # Packages this code!
model_config="../prod_config.yaml"
)
Configuration: prod_config.yaml
Purpose: Production deployment to Model Serving
| File | Purpose | When to Edit |
|---|---|---|
agents/*.py |
Agent implementations | Adding/modifying agents |
core/state.py |
State definitions | Changing state schema |
core/graph.py |
Workflow graph | Changing agent flow |
core/config.py |
Configuration | Adding config values |
tools/*.py |
Agent tools | Adding new tools |
utils/*.py |
Utilities | Adding helpers |
main.py |
CLI entry point | Changing CLI behavior |
# Test imports work
python -c "from src.multi_agent import *; print('โ Imports OK')"
# Run unit tests
pytest tests/unit/ -v
# Test specific agent
pytest tests/unit/test_planning.py -v
# Test locally
python -m src.multi_agent.main --query "test" --verbose
When contributing:
See ../../CONTRIBUTING.md for complete guidelines.
This is the heart of the system! All agent logic lives here. ๐ก