Thanks to visit codestin.com
Credit goes to github.com

Skip to content

mfaraji/nova

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Personal Engineering Manager Agent

A sophisticated Python 3.12 FastAPI + LangGraph backend for an AI-powered Personal Engineering Manager Agent. This system provides intelligent automation for engineering management tasks through a ReAct "Central Brain + Tools" architecture with dynamic knowledge retrieval, enterprise integrations, and scheduled workflows.

πŸš€ Features

Core Capabilities

  • ReAct Central Brain: Single supervisor agent with reasoning, action, and tool orchestration
  • Tool-Based Architecture: Modular tools for memory, retrieval, Jira, Confluence, and Google Drive
  • Dynamic Knowledge Retrieval: Pluggable, metadata-driven knowledge sources
  • Enterprise Integrations: Jira, Confluence, Google Drive with official APIs
  • Scheduled Workflows: Automated standups, project reviews, and grooming
  • Real-time Streaming: Server-Sent Events for live AI responses
  • Persistent Memory: User and project context with vector embeddings
  • LangSmith Integration: Comprehensive tracing and monitoring

Advanced Features

  • One-Best-Tool-First: Calls exactly one tool at a time for efficient execution
  • Capability Scoping: Tools organized by capability (general, memory, jira, confluence)
  • Chain-of-Thought Privacy: Internal reasoning never exposed to users
  • Pluggable Source System: Add new knowledge sources without code changes
  • Circuit Breaking: Resilient error handling and rate limiting
  • Idempotency: Duplicate request prevention with caching
  • Structured Logging: JSON logging with request/session tracking

πŸ—οΈ Architecture

ReAct "Central Brain + Tools" System

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    ReAct Supervisor                        β”‚
β”‚                   (Central Brain)                          β”‚
β”‚                                                             β”‚
β”‚  1. Thought: Analyze request and plan approach             β”‚
β”‚  2. Action: Choose tool call OR provide final answer       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     ToolNode                               β”‚
β”‚              (LangGraph Tool Execution)                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β–Ό           β–Ό           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Memory    β”‚ β”‚  Retrieval  β”‚ β”‚Integration  β”‚
β”‚   Tools     β”‚ β”‚   Tools     β”‚ β”‚   Tools     β”‚
β”‚             β”‚ β”‚             β”‚ β”‚             β”‚
β”‚ β€’ Save      β”‚ β”‚ β€’ Search    β”‚ β”‚ β€’ Jira      β”‚
β”‚ β€’ Get       β”‚ β”‚ β€’ Get       β”‚ β”‚ β€’ Confluenceβ”‚
β”‚ β€’ Search    β”‚ β”‚ β€’ Plan      β”‚ β”‚ β€’ Google    β”‚
β”‚ β€’ Forget    β”‚ β”‚ β€’ Retrieve  β”‚ β”‚ β€’ Drive     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

ReAct Loop Flow

User Query β†’ Supervisor Thinks β†’ Tool Call β†’ Tool Executes β†’ 
Supervisor Thinks β†’ Final Answer β†’ User

Dynamic Knowledge Sources

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Jira Issues    β”‚    β”‚ Confluence Pages β”‚    β”‚  Google Drive   β”‚
β”‚  (Tickets)      β”‚    β”‚  (Documentation) β”‚    β”‚  (Documents)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Enterprise         β”‚
                    β”‚  Retrieval          β”‚
                    β”‚  Orchestrator       β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

agent-manager-backend/
β”œβ”€β”€ πŸ“ app/                          # Main application code
β”‚   β”œβ”€β”€ πŸ“„ main.py                   # FastAPI application entry point
β”‚   β”œβ”€β”€ πŸ“„ config.py                 # Settings and configuration management
β”‚   β”œβ”€β”€ πŸ“„ database.py               # Database connection and session management
β”‚   β”œβ”€β”€ πŸ“„ dependencies.py           # FastAPI dependency injection
β”‚   β”œβ”€β”€ πŸ“„ logging.py                # Structured JSON logging setup
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ models/                   # SQLAlchemy database models
β”‚   β”‚   β”œβ”€β”€ πŸ“„ base.py               # Base model with common fields
β”‚   β”‚   β”œβ”€β”€ πŸ“„ memory.py             # Memory storage model
β”‚   β”‚   β”œβ”€β”€ πŸ“„ message.py            # Chat message model
β”‚   β”‚   └── πŸ“„ session.py            # Chat session model
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ repositories/             # Data access layer
β”‚   β”‚   β”œβ”€β”€ πŸ“„ base_repository.py    # Generic repository pattern
β”‚   β”‚   β”œβ”€β”€ πŸ“„ memory_repository.py  # Memory data operations
β”‚   β”‚   β”œβ”€β”€ πŸ“„ message_repository.py # Message data operations
β”‚   β”‚   └── πŸ“„ session_repository.py # Session data operations
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ routes/                   # FastAPI route handlers
β”‚   β”‚   β”œβ”€β”€ πŸ“„ assistants.py         # Assistant management endpoints
β”‚   β”‚   β”œβ”€β”€ πŸ“„ messages.py           # Message processing endpoints
β”‚   β”‚   β”œβ”€β”€ πŸ“„ monitoring.py         # Health and monitoring endpoints
β”‚   β”‚   β”œβ”€β”€ πŸ“„ scheduler.py          # Scheduled job management
β”‚   β”‚   └── πŸ“„ sessions.py           # Session management endpoints
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ schemas/                  # Pydantic request/response models
β”‚   β”‚   β”œβ”€β”€ πŸ“„ messages.py           # Message schemas
β”‚   β”‚   └── πŸ“„ sessions.py           # Session schemas
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ services/                 # Business logic layer
β”‚   β”‚   β”œβ”€β”€ πŸ“„ embedding_service.py  # Vector embedding generation
β”‚   β”‚   β”œβ”€β”€ πŸ“„ langsmith_service.py  # LangSmith tracing integration
β”‚   β”‚   β”œβ”€β”€ πŸ“„ llm_service.py        # LLM provider management
β”‚   β”‚   β”œβ”€β”€ πŸ“„ message_service.py    # Message processing logic
β”‚   β”‚   β”œβ”€β”€ πŸ“„ scheduler.py          # Job scheduling service
β”‚   β”‚   β”œβ”€β”€ πŸ“„ session_service.py    # Session management logic
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ πŸ“ graph/                # LangGraph ReAct system
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“„ agents.py         # Legacy agent definitions (deprecated)
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“„ graph.py          # ReAct graph orchestration with ToolNode
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“„ state.py          # Agent state management
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“„ supervisor.py     # ReAct supervisor with Union-based actions
β”‚   β”‚   β”‚   └── πŸ“„ utils.py          # Graph utilities
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ πŸ“ integrations/         # External service integrations
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“„ confluence_client.py    # Confluence API client
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“„ confluence_source.py    # Confluence source adapter
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“„ google_source.py        # Google Drive source adapter
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“„ jira_client.py          # Jira API client
β”‚   β”‚   β”‚   └── πŸ“„ jira_source.py          # Jira source adapter
β”‚   β”‚   β”‚
β”‚   β”‚   └── πŸ“ tools/                # LangChain tools and utilities
β”‚   β”‚       β”œβ”€β”€ πŸ“„ confluence_tools.py     # Confluence LangChain tools
β”‚   β”‚       β”œβ”€β”€ πŸ“„ enterprise_retrieval.py # Multi-source orchestration
β”‚   β”‚       β”œβ”€β”€ πŸ“„ google_tools.py         # Google Drive LangChain tools
β”‚   β”‚       β”œβ”€β”€ πŸ“„ jira_tools.py           # Jira LangChain tools
β”‚   β”‚       β”œβ”€β”€ πŸ“„ memory_tools.py         # Memory management tools
β”‚   β”‚       β”œβ”€β”€ πŸ“„ metadata.py             # Tool metadata utilities
β”‚   β”‚       β”œβ”€β”€ πŸ“„ registry.py             # Dynamic tool registry
β”‚   β”‚       β”œβ”€β”€ πŸ“„ retrieval_planner.py    # Source selection planner
β”‚   β”‚       └── πŸ“„ source_protocol.py      # Universal source contract
β”‚   β”‚
β”‚   └── πŸ“ utils/                    # Utility functions
β”‚       β”œβ”€β”€ πŸ“„ idempotency.py        # Idempotency key management
β”‚       └── πŸ“„ sse.py                # Server-Sent Events utilities
β”‚
β”œβ”€β”€ πŸ“ alembic/                      # Database migrations
β”‚   β”œβ”€β”€ πŸ“„ env.py                    # Alembic environment configuration
β”‚   └── πŸ“ versions/                 # Migration files
β”‚       β”œβ”€β”€ πŸ“„ 001_add_pgvector_index.py
β”‚       └── πŸ“„ 002_update_models_jsonb_enums.py
β”‚
β”œβ”€β”€ πŸ“ data/                         # Persistent data storage
β”‚   └── πŸ“ postgres/                 # PostgreSQL data directory
β”‚
β”œβ”€β”€ πŸ“ scripts/                      # Database and setup scripts
β”‚   β”œβ”€β”€ πŸ“„ init-db.sql               # Database initialization
β”‚   └── πŸ“„ setup_checkpointer.py     # LangGraph checkpoint setup
β”‚
β”œβ”€β”€ πŸ“ tests/                        # Test files
β”‚   └── πŸ“„ test_jira_integration.py  # Jira integration tests
β”‚
β”œβ”€β”€ πŸ“„ .env.example                  # Environment configuration template
β”œβ”€β”€ πŸ“„ API.md                        # Comprehensive API documentation
β”œβ”€β”€ πŸ“„ Dockerfile                    # Container definition
β”œβ”€β”€ πŸ“„ docker-compose.yml            # Local development stack
β”œβ”€β”€ πŸ“„ Makefile                      # Development commands
β”œβ”€β”€ πŸ“„ pyproject.toml                # Dependencies and tool configuration
β”œβ”€β”€ πŸ“„ requests.http                 # API testing requests
└── πŸ“„ README.md                     # This file

πŸš€ Quick Start

Prerequisites

  • Python 3.12+
  • uv package manager
  • Docker & Docker Compose (recommended)
  • PostgreSQL 17 with pgvector extension

1. Environment Setup

# Clone the repository
git clone <repository-url>
cd agent-manager-backend

# Copy environment template
cp env.example .env

# Edit configuration
nano .env

2. Configuration

Configure your .env file with the required settings:

# Application
APP_ENV=dev
DATABASE_URL=postgresql+asyncpg://emagent:emagent_password@postgres:5432/emagent

# LLM Provider (choose one)
MODEL_PROVIDER=OPENAI
OPENAI_API_KEY=your_openai_api_key

# Or use Vertex AI
# MODEL_PROVIDER=VERTEX
# GOOGLE_APPLICATION_CREDENTIALS=path/to/credentials.json

# Atlassian Integrations
JIRA_ENABLED=true
JIRA_URL=https://your-domain.atlassian.net
JIRA_USERNAME=[email protected]
JIRA_API_TOKEN=your_api_token

CONFLUENCE_ENABLED=true
CONFLUENCE_URL=https://your-domain.atlassian.net
CONFLUENCE_USERNAME=[email protected]
CONFLUENCE_API_TOKEN=your_api_token

# Google Drive
GOOGLE_DRIVE_ENABLED=true
GOOGLE_CREDENTIALS_JSON_PATH=path/to/service-account.json

# LangSmith Tracing
LANGSMITH_API_KEY=your_langsmith_api_key
LANGSMITH_PROJECT=your_project_name

3. Development with Docker (Recommended)

# Build and start all services
make docker-build
make docker-up

# View logs
make docker-logs

# Get shell access
make docker-shell

# Run tests
make test

4. Local Development

# Install dependencies
make install

# Run database migrations
make migrate

# Start the application
make run

# Test health endpoint
curl http://localhost:8080/healthz

🎯 ReAct System

ReAct Supervisor (Central Brain)

The ReAct Supervisor is the single decision-making agent that:

  1. Analyzes user requests using internal reasoning
  2. Plans the best approach (direct answer vs tool usage)
  3. Acts by either:
    • Providing a final answer for questions it can handle directly
    • Calling exactly one tool to gather needed information
  4. Iterates until it has sufficient information for a complete response

Decision Flow

# ReAct Supervisor Decision Logic
Simple questions (math, general knowledge) β†’ Direct final answer
Memory operations ("remember X", "what is my Y") β†’ Memory tools
Document search ("find documentation") β†’ Retrieval tools  
Jira operations ("create ticket", "search issues") β†’ Jira tools
Confluence operations ("search pages") β†’ Confluence tools
Ambiguous requests β†’ Clarifying question

Available Tools

Tool Category Tools Capabilities
Memory memory_save, memory_get, memory_search, memory_forget Store and retrieve user/project context
Retrieval enterprise_search, plan_retrieval Search across multiple knowledge sources
Jira jira_search, jira_get_issue, jira_create_issue Issue tracking and management
Confluence confluence_search, confluence_get_page Documentation access
Google Drive google_drive_search, google_drive_get Document retrieval

Key Benefits

βœ… Simplified Architecture: Single supervisor replaces complex multi-agent routing
βœ… Flexible Reasoning: General policy allows natural planning vs rigid decision rules
βœ… Efficient Execution: One-best-tool-first approach reduces latency and token usage
βœ… Clean Separation: Internal thoughts never leak to user responses
βœ… Easy Extension: Add new tools by registering them with capabilities
βœ… Better Observability: Structured thoughts preserved for tracing and debugging

πŸ” Dynamic Knowledge Retrieval

Source Architecture

The system uses a pluggable source architecture that allows adding new knowledge sources without modifying agent code:

# Universal Source Contract
class SourceHandle(Protocol):
    def spec(self) -> SourceSpec: ...
    async def search(self, query: str, top_k: int) -> dict: ...
    async def get_by_key(self, key: str) -> dict: ...  # Optional

Available Sources

Source Type Capabilities Key Patterns
Jira Issue tracking Search, Get by key ^[A-Z]{2,10}-\d{1,6}$
Confluence Documentation Search, Get by key ^\d+$ (page IDs)
Google Drive Documents Search None (search-based)

Retrieval Flow

  1. Planning: plan_retrieval_source selects the best source based on:

    • Key pattern matching (e.g., "ABC-123" β†’ Jira)
    • Keyword scoring (e.g., "documentation" β†’ Confluence)
    • Fallback to default source
  2. Execution: Single source search with timeout

  3. Orchestration: If low confidence, enterprise_retrieval fans out to all sources concurrently

  4. Ranking: Results scored by relevance, recency, and source confidence

πŸ”— Enterprise Integrations

Jira Integration

  • Official API: Uses atlassian-python-api library
  • Capabilities: Search, create, update, transition issues
  • Tools: jira_search, jira_get_issue, jira_create_issue, jira_update_issue
  • Source: JiraSource adapter for dynamic retrieval

Confluence Integration

  • Official API: Uses atlassian-python-api library
  • Capabilities: Search pages, get content, manage attachments
  • Tools: confluence_search, confluence_get_page, confluence_get_children
  • Source: ConfluenceSource adapter with metadata enrichment
  • Features: HTML cleanup, caching, rate limiting

Google Drive Integration

  • API: Google Drive API v3
  • Capabilities: Search documents, get content
  • Tools: google_drive_search, google_drive_get_document
  • Source: GoogleSource adapter (placeholder implementation)

⏰ Scheduled Workflows

The ReAct system supports scheduled workflows by sending predefined prompts to the supervisor, which then uses appropriate tools to gather information and generate reports.

Daily Standup (9:00 AM UTC)

  • Trigger: Cron schedule 0 9 * * *
  • Process: ReAct supervisor uses Jira and memory tools to analyze recent activity
  • Output: Yesterday's completed work, today's planned work, blockers

Weekly Project Review (Friday 4:00 PM UTC)

  • Trigger: Cron schedule 0 16 * * 5
  • Process: ReAct supervisor orchestrates Jira, Confluence, and memory tools
  • Output: Comprehensive project status with milestones, risks, next steps

Grooming Sweep (Mon/Wed/Fri 10:00 AM UTC)

  • Trigger: Cron schedule 0 10 * * 1,3,5
  • Process: ReAct supervisor analyzes backlog using Jira tools
  • Output: Backlog analysis and grooming recommendations (requires approval)

πŸ› οΈ Development Commands

Make Commands

# Setup and Installation
make install          # Install dependencies
make dev              # Install development dependencies
make migrate          # Run database migrations

# Development
make run              # Start application locally
make docker-build     # Build Docker image
make docker-up        # Start Docker services
make docker-down      # Stop Docker services
make docker-logs      # View Docker logs
make docker-shell     # Get Docker shell access

# Code Quality
make lint             # Run linting (ruff + mypy)
make format           # Format code (black + ruff --fix)
make test             # Run tests
make clean            # Clean generated files

# Utilities
make help             # Show all available commands

πŸ“Š API Endpoints

Core Endpoints

Method Endpoint Description
GET /healthz Health check
GET /config Application configuration
GET /assistants List available assistants
GET /assistants/{id} Get assistant details

Session Management

Method Endpoint Description
POST /sessions Create new session
GET /sessions List sessions
GET /sessions/{id} Get session details
POST /threads Create thread (LangGraph compatible)
GET /threads List threads

Message Processing

Method Endpoint Description
POST /messages Send message (non-streaming)
GET /stream Stream response (SSE)
POST /threads/{id}/runs Send message to thread
GET /chat/stream Agent Chat UI compatible streaming

Monitoring

Method Endpoint Description
GET /monitoring/health/detailed Detailed system health
GET /monitoring/langsmith LangSmith tracing status
GET /scheduler/status Scheduler status and jobs

πŸ”§ Configuration

Environment Variables

Variable Description Default Required
APP_ENV Environment (dev/prod) dev No
DATABASE_URL PostgreSQL connection string - Yes
MODEL_PROVIDER LLM provider (OPENAI/VERTEX/MOCK) MOCK No
OPENAI_API_KEY OpenAI API key - If using OpenAI
JIRA_ENABLED Enable Jira integration false No
JIRA_URL Jira instance URL - If Jira enabled
JIRA_USERNAME Jira username/email - If Jira enabled
JIRA_API_TOKEN Jira API token - If Jira enabled
CONFLUENCE_ENABLED Enable Confluence integration false No
CONFLUENCE_URL Confluence instance URL - If Confluence enabled
CONFLUENCE_USERNAME Confluence username/email - If Confluence enabled
CONFLUENCE_API_TOKEN Confluence API token - If Confluence enabled
GOOGLE_DRIVE_ENABLED Enable Google Drive integration false No
GOOGLE_CREDENTIALS_JSON_PATH Service account JSON path - If Google Drive enabled
LANGSMITH_API_KEY LangSmith API key - No
LANGSMITH_PROJECT LangSmith project name - No

Database Configuration

The system uses PostgreSQL 17 with the pgvector extension for vector embeddings:

-- Required extensions
CREATE EXTENSION IF NOT EXISTS vector;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

LLM Provider Configuration

OpenAI

MODEL_PROVIDER=OPENAI
OPENAI_API_KEY=sk-...

Google Vertex AI

MODEL_PROVIDER=VERTEX
GOOGLE_APPLICATION_CREDENTIALS=path/to/credentials.json

Mock (Development)

MODEL_PROVIDER=MOCK
# No additional configuration required

πŸ§ͺ Testing

Running Tests

# Run all tests
make test

# Run specific test file
docker-compose exec app python -m pytest tests/test_jira_integration.py

# Run with coverage
docker-compose exec app python -m pytest --cov=app tests/

Test Structure

tests/
β”œβ”€β”€ test_jira_integration.py    # Jira API integration tests
β”œβ”€β”€ test_confluence_integration.py  # Confluence API tests (to be added)
β”œβ”€β”€ test_retrieval_system.py    # Dynamic retrieval system tests (to be added)
└── test_agents.py              # Agent behavior tests (to be added)

πŸ“ˆ Monitoring & Observability

LangSmith Integration

All agent interactions are traced in LangSmith:

Structured Logging

The system uses structured JSON logging with:

  • Request tracking: Unique request IDs
  • Session context: User and session information
  • Agent execution: Step-by-step agent decisions
  • Error tracking: Detailed error information with stack traces

Health Monitoring

  • Basic health: /healthz endpoint
  • Detailed health: /monitoring/health/detailed with integration status
  • Scheduler status: /scheduler/status with job information
  • LangSmith status: /monitoring/langsmith with tracing configuration

πŸš€ Deployment

Docker Deployment

# Build production image
docker build -t em-agent:latest .

# Run with production configuration
docker run -d \
  --name em-agent \
  -p 8080:8080 \
  --env-file .env.prod \
  em-agent:latest

Environment-Specific Configuration

Development

APP_ENV=dev
MODEL_PROVIDER=MOCK
LANGSMITH_ENABLED=false

Production

APP_ENV=prod
MODEL_PROVIDER=OPENAI
OPENAI_API_KEY=sk-...
LANGSMITH_ENABLED=true
LANGSMITH_API_KEY=ls__...

πŸ”’ Security Features

Execution Limits

  • MAX_STEPS: Maximum agent execution steps (default: 6)
  • MAX_TOKENS: Maximum token usage (default: 4096)
  • COST_CAP_USD: Maximum API cost per request (default: 0)

Idempotency

  • Idempotency-Key: Prevents duplicate message processing
  • Response Caching: Cached responses for duplicate requests
  • Session-based: Idempotency scoped to sessions

ReAct Loop Controls

  • Single Tool Execution: Only one tool called per iteration
  • Thought Privacy: Internal reasoning never exposed to users
  • Capability Scoping: Tools filtered by relevance to reduce attack surface
  • Early Termination: Stops as soon as sufficient information is available

🀝 Contributing

Development Workflow

  1. Fork and clone the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make changes following the code style guidelines
  4. Run tests: make test
  5. Run linting: make lint
  6. Commit changes: git commit -m 'Add amazing feature'
  7. Push to branch: git push origin feature/amazing-feature
  8. Open a Pull Request

Code Style

The project uses:

  • Black for code formatting
  • Ruff for linting and import sorting
  • MyPy for type checking
  • 88 character line length limit

Adding New Tools to ReAct System

To add a new tool that the ReAct supervisor can use:

  1. Create the tool in app/services/tools/:

    from langchain_core.tools import tool
    
    @tool("my_new_tool")
    async def my_new_tool(param1: str, param2: int = 5) -> dict:
        """Tool description that the supervisor will see."""
        # Tool logic here
        return {"ok": True, "result": "success"}
  2. Register with capabilities in app/services/tools/registry.py:

    # In _build_entries method
    new_tools = [(lambda: my_new_tool, ToolMetadata(
        capabilities=["general", "my_capability"],
        vendor="internal",
        rate_limit_per_minute=60
    ))]
    general.extend(new_tools)
  3. The ReAct supervisor automatically discovers and can use the new tool

Adding New Sources

To add a new knowledge source:

  1. Create source adapter in app/services/integrations/:

    class NewSource(SourceHandle):
        def spec(self) -> SourceSpec:
            return SourceSpec(
                id="new_source",
                display_name="New Source",
                capabilities={"search"},
                keywords={"keyword1", "keyword2"},
                key_regex=r"^PATTERN$",
                per_call_timeout_s=3,
                default_top_k=5
            )
  2. Register in registry in app/services/tools/registry.py:

    if getattr(settings, "new_source_enabled", False):
        self._source_factories.append(lambda: NewSource())
  3. Add configuration in app/config.py:

    new_source_enabled: bool = Field(default=False)
    new_source_url: str = Field(default="")
    new_source_api_key: str = Field(default="")

πŸ“š Additional Resources

Documentation

External Tools

Example Requests

  • requests.http: Contains example API requests for testing

πŸ› Troubleshooting

Common Issues

Docker Issues

# Reset Docker environment
make docker-down
docker system prune -f
make docker-build
make docker-up

Database Issues

# Reset database
docker-compose down -v
docker-compose up -d postgres
make migrate

Virtual Environment Issues

# Recreate virtual environment
rm -rf .venv
make install

Debug Mode

Enable debug logging:

LOG_LEVEL=DEBUG

Performance Issues

  • Check LangSmith traces for agent execution bottlenecks
  • Monitor database queries with PostgreSQL logs
  • Review source timeouts in retrieval orchestrator
  • Check rate limiting in integration clients

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • ReAct Pattern from "ReAct: Synergizing Reasoning and Acting in Language Models" (Yao et al., 2022)
  • LangChain for the tool-based framework and structured output
  • LangGraph for ReAct orchestration and ToolNode execution
  • FastAPI for the web framework
  • Atlassian for official Python APIs
  • PostgreSQL and pgvector for vector storage

Built with ❀️ for Engineering Managers everywhere
Now powered by ReAct "Central Brain + Tools" architecture

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages