-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
agenticAgentic AI featuresAgentic AI featuresbackendBackend/API relatedBackend/API relatedenhancementNew feature or requestNew feature or requestpriority:mediumMedium priority - nice to haveMedium priority - nice to haveragRAG pipeline and searchRAG pipeline and search
Description
Summary
Implement the 3-stage agent execution hook system in SearchService to enable AI agents to enhance, transform, and augment the search pipeline at strategic points.
Background
This implements the architecture defined in docs/architecture/search-agent-hooks-architecture.md. Agents can be injected at three stages:
- Pre-Search Agents - Transform/enhance query before vector search
- Post-Search Agents - Process/filter documents before answer generation
- Response Agents - Generate artifacts from final answer (parallel execution)
Pipeline Flow
User Query
│
▼
┌─────────────────────────────────────┐
│ STAGE 1: PRE-SEARCH AGENTS │
│ • Query Expander │
│ • Language Detector/Translator │
│ • Acronym Resolver │
│ • Intent Classifier │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ CORE RAG SEARCH (unchanged) │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ STAGE 2: POST-SEARCH AGENTS │
│ • Re-ranker │
│ • Deduplicator │
│ • External Enricher │
│ • PII Redactor │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ ANSWER GENERATION (unchanged) │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ STAGE 3: RESPONSE AGENTS │
│ • PowerPoint Generator │
│ • PDF Report Generator │
│ • Chart Generator │
│ • Audio Summary │
│ (Runs in PARALLEL) │
└─────────────────────────────────────┘
│
▼
Final Response with Artifacts
Implementation Tasks
Database Schema
- Create
agent_configstable (user's agent configurations) - Create
collection_agentsjunction table (collection ↔ agent association) - Add indexes for efficient lookups
Backend Components
-
AgentContextdataclass for passing state through pipeline -
AgentResultdataclass for agent responses - Agent executor for each stage in SearchService
- Pre-search agent hook (sequential by priority)
- Post-search agent hook (sequential by priority)
- Response agent hook (parallel execution)
- Circuit breaker for agent failures
API Endpoints
- GET
/api/agents/configs- List user's agent configs - POST
/api/agents/configs- Create agent config - PATCH
/api/agents/configs/{id}- Update agent config - DELETE
/api/agents/configs/{id}- Delete agent config - GET
/api/collections/{id}/agents- List collection's agents - POST
/api/collections/{id}/agents- Add agent to collection - DELETE
/api/collections/{id}/agents/{agent_id}- Remove agent - PATCH
/api/agents/configs/priorities- Batch update priorities
Search Response Enhancement
- Add
agent_artifactsfield to SearchResponse - Add
agent_executionsfield for tracking - Add
pipeline_metadatafor timing info
Dependencies
- PR feat: SPIFFE/SPIRE Integration Architecture for Agent Identity #695 (SPIFFE/SPIRE agent identity) - merged
- PR feat(mcp): Add MCP Gateway integration for tool invocation and enrichment #671 (MCP Gateway client) - for calling external agent tools
Acceptance Criteria
- Agents execute at correct pipeline stages
- Pre/post-search agents run sequentially by priority
- Response agents run in parallel
- Agent failures are isolated (don't break search)
- Collection ↔ Agent associations persist correctly
- Agent artifacts returned in SearchResponse
- Unit tests with 80%+ coverage
- Integration tests for full pipeline
References
- Architecture:
docs/architecture/search-agent-hooks-architecture.md - Epic: [EPIC] Future: Agentic AI Platform v2 (Phase 4) #691
Metadata
Metadata
Assignees
Labels
agenticAgentic AI featuresAgentic AI featuresbackendBackend/API relatedBackend/API relatedenhancementNew feature or requestNew feature or requestpriority:mediumMedium priority - nice to haveMedium priority - nice to haveragRAG pipeline and searchRAG pipeline and search