tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Generative AI > Google Gemini API > ADK Multi-Tenancy Patterns

ADK Multi-Tenancy Patterns

Author: Venkata Sudhakar

Multi-tenancy allows a single ADK agent deployment to serve multiple independent business units or customers while keeping their data, sessions, and tool permissions completely isolated. ShopMax India runs separate portals for Retail, Wholesale, and Corporate clients � each tenant must never see another tenant's data or trigger another tenant's tools.

The key to multi-tenancy in ADK is propagating a tenant identifier through every layer: session state, tool invocations, database queries, and audit logs. The agent reads the tenant ID from the authenticated request context and uses it as a mandatory filter on every operation.

The below example shows a multi-tenant ADK agent that enforces tenant isolation using session state and tenant-scoped tool wrappers.


It gives the following output,

# POST /agent  Headers: X-Tenant-ID: retail
# Body: {"message": "Show pending orders", "session_id": "u100"}
{
  "tenant": "retail",
  "reply": "You have 3 pending retail orders: ORD-1001 (Rs 4,500), ORD-1002 (Rs 12,200), ORD-1003 (Rs 890)."
}

# POST /agent  Headers: X-Tenant-ID: wholesale
# Body: {"message": "Show pending orders", "session_id": "u200"}
{
  "tenant": "wholesale",
  "reply": "You have 1 pending wholesale order: ORD-2041 (Rs 1,85,000)."
}

For production, replace InMemorySessionService with a Firestore-backed session store keyed by tenant, enable VPC Service Controls to prevent cross-tenant BigQuery access at the network layer, and rotate the signing key used to verify X-Tenant-ID claims. Logging each request with the tenant label in Cloud Logging enables per-tenant usage auditing.


 
  


  
bl  br