Skip to content

Conversation

@i3xpl0it
Copy link

@i3xpl0it i3xpl0it commented Dec 7, 2025

This document provides a comprehensive guide on building a production-grade multi-agent Retrieval-Augmented Generation (RAG) system using Snowflake Gen2 Warehouses and Cortex. It includes architecture, setup instructions, and sample queries.

This document provides a comprehensive guide on building a production-grade multi-agent Retrieval-Augmented Generation (RAG) system using Snowflake Gen2 Warehouses and Cortex. It includes architecture, setup instructions, and sample queries.
@snowflake-github-workato
Copy link

https://publish-p57963-e462098.adobeaemcloud.com/en/developers/guides/multi-agent-rag-gen2-cortex-aca26adc7339a66444807969911d6b1e2b46f366

Note: The image uploads happen async, so they may not be uploaded yet if you click this quickly.. try again in a few minutes if so.

- Complete 6-agent architecture with full SQL/Python implementations
- Semantic chunking UDF + Cortex embeddings + external vector DB
- Gen2 warehouse optimization with 30-50% performance gains
- Production deployment, monitoring, and troubleshooting guides
- Based on Medium article about multi-agent RAG with Gen2 warehouses
@snowflake-github-workato
Copy link

https://publish-p57963-e462098.adobeaemcloud.com/en/developers/guides/multi-agent-rag-gen2-cortex-e04e706b971827f41ed49ba0287421430705df5d

Note: The image uploads happen async, so they may not be uploaded yet if you click this quickly.. try again in a few minutes if so.

Updated duration formatting throughout the document to include 'Hours'.
@snowflake-github-workato
Copy link

https://publish-p57963-e462098.adobeaemcloud.com/en/developers/guides/multi-agent-rag-gen2-cortex-0589dc172ef157936afde65098b71db87987ffc2

Note: The image uploads happen async, so they may not be uploaded yet if you click this quickly.. try again in a few minutes if so.

Updated duration estimates for various sections of the document to reflect more accurate time requirements.
Added overview section for multi-agent RAG system.
@snowflake-github-workato
Copy link

https://publish-p57963-e462098.adobeaemcloud.com/en/developers/guides/multi-agent-rag-gen2-cortex-87789cb730a5cc8708008258f86ac53587463424

Note: The image uploads happen async, so they may not be uploaded yet if you click this quickly.. try again in a few minutes if so.

@snowflake-github-workato
Copy link

https://publish-p57963-e462098.adobeaemcloud.com/en/developers/guides/multi-agent-rag-gen2-cortex-a588d3148d251855f1045391fba1d55e7d284ea9

Note: The image uploads happen async, so they may not be uploaded yet if you click this quickly.. try again in a few minutes if so.

@i3xpl0it
Copy link
Author

i3xpl0it commented Dec 8, 2025

Could a maintainer please assign a reviewer for this PR? This guide covers building a production-grade multi-agent RAG system using Snowflake Gen2 Warehouses and Cortex. Thank you!

Copy link
Contributor

@sfc-gh-jreini sfc-gh-jreini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested some changes


nltk.download('punkt', quiet=True)

def chunk_doc(doc_text: str) -> List[str]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use native PARSE_DOCUMENT feature instead of python UDF?

import numpy as np
import _snowflake

def search_vectors(query_embedding: list, top_k: int) -> list:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you replicate this with cortex search instead of pinecone? Or is the pinecone integration something you're trying to show in the guide?

### Create Document Retriever Agent

```sql
CREATE OR REPLACE FUNCTION document_retriever_agent(user_query STRING)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems more like a retrieval tool than an agent - no agent reasoning is used here, just returning documents. suggest renaming

```

## Agent 2: SQL Generator
Duration: 1.5 Hours
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very long duration here, intended?

LANGUAGE SQL
AS
$$
SELECT SNOWFLAKE.CORTEX.COMPLETE(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use AI_COMPLETE instead of SNOWFLAKE.CORTEX.COMPLETE

### Create SQL Generation Agent

```sql
CREATE OR REPLACE FUNCTION sql_generator_agent(user_question STRING)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use cortex analyst instead of hand-rolling this sql generator agent. Quality of sql generation will be much higher and more extensible.

### Business Logic Layer

```sql
CREATE OR REPLACE FUNCTION semantic_model_agent(entity STRING, operation STRING)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this agent doing?

synthesized_response AS (
SELECT
SNOWFLAKE.CORTEX.COMPLETE(
'mixtral-8x7b',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would recommend using a stronger model here

AS
$$
WITH agent_results AS (
-- Execute all agents in parallel on Gen2 warehouse
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why execute all agents in parallel if they may not be needed depending on query?

Better to have the coordinator agent do planning/tool selection instead of just using all of the agents at once no matter what.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants