Skip to content

Commit dee5af0

Browse files
committed
feat(rag): Complete RAG prompt refactoring and bug fixes
- Removed all hardcoded prompts from RAG agents - Created 3 new prompts for RAG Swarm Coordinator: * document_grader_v1: Document relevance grading * query_rewriter_v1: Query optimization for retrieval * answer_generator_v1: Answer synthesis from context - Refactored rag_swarm_coordinator.py to use AgentPromptLoader - Refactored writer_agent.py to use AgentPromptLoader - All 9 RAG prompts now in LangSmith Hub with proper tags - Fixed critical bug: Changed ToolMessage detection from msg.type to isinstance() - Fixed bug: Collect ALL tool results, not just last message - Changed model from gemini-2.0-flash-exp to gemini-2.5-flash (consistency) - Added system message to force tool usage in agent node - Enhanced LangSmith tracing setup in RAG Management App - Added visual tracing indicator in UI Related: US-RAG-004, US-SWARM-002, Sprint 6
1 parent 62ccecb commit dee5af0

File tree

77 files changed

+6974
-458
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+6974
-458
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ chroma.sqlite3
150150
.env.temp
151151
secrets.json
152152
secrets.toml
153+
.google_cloud/
153154

154155
# Build artifacts
155156
dist/

agents/rag/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
from agents.rag.re_ranker_agent import ReRankerAgent
1111
from agents.rag.quality_assurance_agent import QualityAssuranceAgent
1212
from agents.rag.writer_agent import WriterAgent
13+
from agents.rag.rag_swarm_coordinator import RAGSwarmCoordinator
1314

1415
__all__ = [
1516
'QueryAnalystAgent',
1617
'RetrievalSpecialistAgent',
1718
'ReRankerAgent',
1819
'QualityAssuranceAgent',
1920
'WriterAgent',
21+
'RAGSwarmCoordinator',
2022
]
2123

agents/rag/query_analyst_agent.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -179,25 +179,10 @@ async def _analyze_query_with_llm(self, query: str) -> Dict[str, Any]:
179179
convert_system_message_to_human=True
180180
)
181181

182-
# Create analysis prompt
183-
system_prompt = """You are a Query Analysis Expert for a RAG (Retrieval Augmented Generation) system.
184-
185-
Your task is to analyze user queries and provide:
186-
1. Intent classification (factual, conceptual, procedural, multi-hop, exploratory)
187-
2. 3-5 rewritten query variants optimized for semantic search
188-
3. Key concepts/terms that should be searched
189-
4. Recommended search strategy (focused, broad, multi-stage)
190-
5. Complexity score (0.0-1.0)
191-
192-
Respond in this exact JSON format:
193-
{
194-
"intent": "factual|conceptual|procedural|multi-hop|exploratory",
195-
"rewritten_queries": ["variant1", "variant2", "variant3"],
196-
"key_concepts": ["concept1", "concept2", "concept3"],
197-
"search_strategy": "focused|broad|multi-stage",
198-
"complexity": 0.5,
199-
"reasoning": "Brief explanation"
200-
}"""
182+
# Load prompt from LangSmith (following langgraph_workflow pattern)
183+
from prompts.agent_prompt_loader import get_agent_prompt_loader
184+
prompt_loader = get_agent_prompt_loader("query_analyst")
185+
system_prompt = prompt_loader.get_system_prompt()
201186

202187
user_prompt = f"""Analyze this query:
203188

0 commit comments

Comments
 (0)