- System Overview
- Architecture Principles
- Core Components
- Data Flow
- System Layers
- Component Details
- Communication Patterns
- Storage & Persistence
- Scalability & Performance
- Security Considerations
SentientResearchAgent is built as a modular, event-driven system with clear separation of concerns:
graph TB
subgraph "Frontend Layer"
UI[React UI]
WS[WebSocket Client]
end
subgraph "API Layer"
Flask[Flask Server]
SIOHTTP[SocketIO HTTP]
REST[REST API]
end
subgraph "Core System"
SM[SystemManager]
EE[ExecutionEngine]
TG[TaskGraph]
KS[KnowledgeStore]
end
subgraph "Agent Layer"
AR[AgentRegistry]
PA[Planner Agents]
EA[Executor Agents]
AA[Aggregator Agents]
end
subgraph "Storage Layer"
Cache[Cache Manager]
Proj[Project Storage]
Logs[Trace Logs]
end
UI <--> WS
WS <--> SIOHTTP
UI <--> REST
REST <--> Flask
Flask <--> SM
SM <--> EE
EE <--> TG
EE <--> KS
EE <--> AR
AR <--> PA
AR <--> EA
AR <--> AA
SM <--> Cache
SM <--> Proj
EE <--> Logs
- Tasks are recursively broken down into subtasks
- Each level maintains its own context and state
- Bottom-up result aggregation
- Agents are pluggable components
- Each agent has a specific role and interface
- Easy to add new agent types
- State changes trigger events
- Loosely coupled components communicate via events
- Real-time updates through WebSocket
- Information flows intelligently between tasks
- Results are cached and reused
- No context loss between operations
- HITL (Human-in-the-Loop) at critical decision points
- Real-time visualization of execution
- Intervention and modification capabilities
The central orchestrator that initializes and manages all system components:
class SystemManagerV2:
- config: SentientConfig
- task_graph: TaskGraph
- knowledge_store: KnowledgeStore
- execution_orchestrator: ExecutionOrchestrator
- agent_registry: AgentRegistry
- hitl_service: HITLServiceResponsibilities:
- Component lifecycle management
- Configuration propagation
- Profile loading and management
- WebSocket HITL setup
Manages the hierarchical structure of tasks:
class TaskGraph:
- nodes: Dict[str, TaskNode]
- edges: Set[Tuple[str, str]]
- sub_graphs: Dict[str, TaskGraph]Features:
- Directed acyclic graph (DAG) structure
- Sub-graph support for hierarchical decomposition
- Dependency tracking
- Cycle detection
The atomic unit of work:
class TaskNode:
- task_id: str
- goal: str
- task_type: TaskType (SEARCH, WRITE, THINK)
- node_type: NodeType (PLAN, EXECUTE)
- status: TaskStatus
- layer: int
- result: Any
- sub_graph_id: Optional[str]States:
PENDING→READY→RUNNING→DONE/FAILEDPLAN_DONE→AGGREGATING→DONE(for PLAN nodes)
Orchestrates task execution:
class ExecutionEngine:
- run(): Main execution loop
- process_ready_nodes(): Process nodes ready for execution
- update_node_statuses(): State transition managementExecution Strategy:
- Concurrent execution of independent tasks
- Dependency-aware scheduling
- Deadlock detection and recovery
Handles individual node processing:
class NodeProcessor:
- process_node(): Main processing entry point
- _process_plan_node(): Handle planning tasks
- _process_execute_node(): Handle execution tasks
- _process_aggregation(): Handle result aggregationProcessing Flow:
- Atomization check (can task be executed directly?)
- Context building (gather relevant information)
- Agent selection and invocation
- Result storage and propagation
Manages available agents:
class AgentRegistry:
- register_agent(): Add new agent
- get_agent(): Retrieve agent by criteria
- list_agents(): Get available agentsAgent Types:
- Atomizers: Determine if task needs decomposition
- Planners: Break down complex tasks
- Executors: Perform actual work
- Aggregators: Combine results
Manages execution context and results:
class KnowledgeStore:
- store_result(): Save task results
- get_relevant_results(): Retrieve context
- get_lineage_results(): Get parent/sibling resultssequenceDiagram
participant User
participant API
participant SystemManager
participant TaskGraph
participant ExecutionEngine
User->>API: Submit task
API->>SystemManager: Initialize execution
SystemManager->>TaskGraph: Create root node
SystemManager->>ExecutionEngine: Start execution
ExecutionEngine->>TaskGraph: Update node status
sequenceDiagram
participant ExecutionEngine
participant NodeProcessor
participant Agent
participant KnowledgeStore
participant HITL
ExecutionEngine->>NodeProcessor: Process node
NodeProcessor->>Agent: Check atomization
Agent-->>NodeProcessor: Atomic/Complex
alt Complex Task
NodeProcessor->>HITL: Request plan review
HITL-->>NodeProcessor: Approved/Modified
NodeProcessor->>Agent: Generate plan
Agent-->>NodeProcessor: Sub-tasks
NodeProcessor->>TaskGraph: Create sub-graph
else Atomic Task
NodeProcessor->>KnowledgeStore: Get context
KnowledgeStore-->>NodeProcessor: Relevant results
NodeProcessor->>Agent: Execute task
Agent-->>NodeProcessor: Result
NodeProcessor->>KnowledgeStore: Store result
end
sequenceDiagram
participant ExecutionEngine
participant NodeProcessor
participant Aggregator
participant KnowledgeStore
participant TaskGraph
ExecutionEngine->>TaskGraph: Check sub-tasks complete
TaskGraph-->>ExecutionEngine: All done
ExecutionEngine->>NodeProcessor: Aggregate results
NodeProcessor->>KnowledgeStore: Get child results
KnowledgeStore-->>NodeProcessor: Results array
NodeProcessor->>Aggregator: Combine results
Aggregator-->>NodeProcessor: Aggregated result
NodeProcessor->>TaskGraph: Update parent node
Frontend (React/TypeScript)
- Real-time task visualization
- HITL interaction interfaces
- WebSocket event handling
- State management (Zustand)
Key Components:
TaskGraphVisualization: Visual task treeHITLModal: Human review interfaceWebSocketManager: Real-time communication
Flask Server
- RESTful endpoints for CRUD operations
- WebSocket support via SocketIO
- Request validation and routing
Endpoints:
/api/projects/*: Project management/api/execute: Task execution/api/websocket: Real-time events
Core Services:
- Task decomposition and planning
- Agent selection and invocation
- Context building and propagation
- State management and transitions
Storage Components:
- File-based project persistence
- Optional S3 mounting integration via goofys
- In-memory knowledge store
- Cache management
- Trace logging
// Frontend → Backend
interface ExecuteRequest {
goal: string;
profile?: string;
config?: ExecutionConfig;
}
// Backend → Frontend
interface TaskUpdate {
node: TaskNode;
graph: TaskGraph;
timestamp: number;
}interface HITLRequest {
checkpoint: string;
node_id: string;
context: any;
data_for_review: any;
}
interface HITLResponse {
action: 'approve' | 'modify' | 'abort';
modification_instructions?: string;
}# Agent Input
class AgentTaskInput:
task: TaskNode
relevant_context: List[Dict[str, Any]]
# Agent Output
class AgentOutput:
result: Any
confidence: float
metadata: Dict[str, Any]runtime/projects/
├── project_id/
│ ├── metadata.json
│ ├── task_graph.json
│ ├── knowledge_store.json
│ └── traces/
runtime/cache/
├── agent/
│ ├── response_cache.json
│ └── context_cache.json
experiments/emergency_backups/
├── execution_id_timestamp_emergency.json
- Batched Updates: Reduce WebSocket message frequency
- Cached Context: Reuse computed contexts
- Parallel Execution: Process independent tasks concurrently
- Lazy Loading: Load data only when needed
execution:
max_concurrent_nodes: 10
state_batch_size: 50
ws_batch_timeout_ms: 100
enable_immediate_slot_fill: true- Agent Response Caching: Reduce LLM API calls
- Context Compression: Minimize memory usage
- Smart Scheduling: Prioritize critical path tasks
- Input validation and sanitization
- Rate limiting per endpoint
- API key management
- Sensitive data exclusion from logs
- Secure storage of API keys
- User data isolation
- Agent sandboxing
- Resource limits
- Timeout enforcement
- Natural problem decomposition
- Parallel execution opportunities
- Clear progress tracking
- Human-understandable structure
- Specialization for different tasks
- Easy extensibility
- Provider independence
- Community contribution
- Real-time updates
- Loose coupling
- Better testability
- Scalable architecture
- Quality control
- Continuous improvement
- Trust building
- Training data generation
- Distributed execution support
- Enhanced caching strategies
- Plugin architecture
- Metrics and monitoring
- Better context management
- Task-focused, independet sub-agents
- Multi-agent collaboration protocols
- Self-modifying task graphs
- Cross-system federation
- Blockchain-based agent marketplace
- Core Concepts - Understand the fundamental concepts
- Execution Flow - Detailed execution walkthrough
- Agent Guide - Working with the agent system
- API Reference - Complete API documentation