A step-by-step guide to building a routing agent in Snowflake that automatically dispatches user questions to the most appropriate Cortex Agent. The solution uses an auto-syncing agent registry, Cortex Search for semantic matching, native RBAC filtering, and multi-turn conversation thread tracking — all in pure SQL with no Python dependencies. Key components include a sync procedure that discovers agents hourly, a Cortex Search service for natural language matching, an RBAC filter using SHOW GRANTS, thread mappings for conversation continuity, and a routing agent orchestrated with Claude that ties everything together. The complete code is available in a companion GitHub repository.

13m read timeFrom medium.com
Post cover image
Table of contents
Overwhelmed by agents? Let’s build a single routing agent to seamlessly direct user requests to the appropriate Cortex Agent.Enter the Routing AgentArchitecture OverviewStep 1: Create the SchemaStep 2: Create the Agent RegistryStep 3: Sync Procedure — Auto-Discover AgentsStep 4: Cortex Search ServiceGet Garland Pope’s stories in your inboxStep 5: RBAC FilterStep 6: Thread Mappings for Multi-Turn ConversationsStep 7: Invoke Agent ProcedureStep 8: Create the Routing AgentWrapping Up

Sort: