Skip to content

N-45div/PassedAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PassedAI ๐Ÿ”

Multi-agent knowledge decay auditor โ€” Built for the Elasticsearch Agent Builder Hackathon

License: MIT Elasticsearch Agent Builder


๐ŸŽฏ The Problem

Enterprise knowledge bases decay silently. Documentation becomes outdated, contradictory, or concentrated in the hands of a few experts โ€” creating operational risk that's invisible until something breaks.

PassedAI detects four types of knowledge decay automatically:

Decay Type What It Catches Business Impact
๐Ÿ• Stale Docs Documents not updated in 6-24+ months Employees following outdated procedures
โš”๏ธ Contradictions Two docs giving opposite guidance on the same topic Confusion, compliance risk
โ“ Knowledge Gaps Repeated employee questions with no matching documentation Tribal knowledge, onboarding friction
๐Ÿ‘ค Expert Risk Single owners of critical documentation Bus factor = 1, knowledge silos

๐Ÿ—๏ธ Architecture

flowchart TB
    subgraph UI["๐Ÿ–ฅ๏ธ Demo UI (Flask :5050)"]
        Dashboard["Real-time Dashboard"]
    end

    subgraph Orchestrator["๐Ÿ Python Orchestrator"]
        RunAudit["run_audit.py"]
        A2AClient["a2a_client.py"]
    end

    subgraph AgentBuilder["โšก Elastic Agent Builder"]
        subgraph Detect["PassedAI-Detect"]
            D1["staleness_scorer"]
            D2["gap_detector"]
            D3["contradiction_finder"]
            D4["expert_risk_finder"]
        end
        subgraph Act["PassedAI-Act"]
            A1["notify_owner"]
            A2["create_gap_task"]
        end
    end

    subgraph ES["๐Ÿ” Elasticsearch Serverless"]
        Docs["passed_documents<br/>200 docs + ELSER v2"]
        Questions["passed_questions<br/>60 questions + ELSER v2"]
        AuditLog["passed_audit_log"]
        Notifications["passed_notifications"]
    end

    Reports["๐Ÿ“„ Audit Reports<br/>data/reports/*.md"]

    Dashboard -->|REST API| ES
    RunAudit -->|A2A| Detect
    Detect -->|ESQL| ES
    Detect -->|Findings| RunAudit
    RunAudit -->|A2A| Act
    Act -->|Actions| Notifications
    RunAudit --> Reports
Loading

Data Flow

sequenceDiagram
    participant O as Orchestrator
    participant D as Detect Agent
    participant A as Act Agent
    participant ES as Elasticsearch

    O->>D: A2A message/send audit prompt
    D->>ES: ESQL staleness_scorer
    D->>ES: ESQL gap_detector
    D->>ES: ESQL contradiction_finder
    D->>ES: ESQL expert_risk_finder
    D-->>O: Structured findings STALE/GAP/CONTRADICTION/EXPERT_RISK
    
    O->>A: A2A message/send (findings)
    A-->>O: ACTION lines + ACTION_SUMMARY
    
    O->>O: Write markdown report
Loading

โœจ Elastic Features Used

Feature Implementation Purpose
ES|QL Tools 4 custom queries in Agent Builder Detect stale docs, gaps, contradictions, expert risk
A2A Protocol JSON-RPC 2.0 message/send Orchestrator โ†” Agent communication
ELSER v2 semantic_text field type Semantic search for contradiction detection
Agent Builder 2 agents with custom system prompts Detect + Act multi-agent pattern
Serverless Elastic Cloud Serverless Zero-ops deployment

๐Ÿ“Š Demo Results

Sample audit output from synthetic data:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ PassedAI Audit                             โ”‚
โ”‚ Run ID: 0ec4c448  Window: 90d  Top-N: 10   โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

         Detect Results           
                                   
  Category                  Count  
 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ 
  Stale docs (score โ‰ฅ 70)      20  
  Knowledge gaps                1  
  Contradiction pairs           2  
  Expert risk owners            8  

Dashboard Screenshot: The Flask UI at localhost:5050 shows real-time stats pulled from Elasticsearch.


๐Ÿ“ Repository Structure

PassedAI/
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ agent_prompts/           # System prompts for both agents
โ”‚   โ”‚   โ”œโ”€โ”€ detect_agent.md
โ”‚   โ”‚   โ””โ”€โ”€ act_agent.md
โ”‚   โ”œโ”€โ”€ esql/                    # ES|QL tool queries
โ”‚   โ”‚   โ”œโ”€โ”€ staleness_scorer.esql
โ”‚   โ”‚   โ”œโ”€โ”€ gap_detector.esql
โ”‚   โ”‚   โ”œโ”€โ”€ contradiction_finder.esql
โ”‚   โ”‚   โ””โ”€โ”€ expert_risk_finder.esql
โ”‚   โ””โ”€โ”€ index_mappings/          # Elasticsearch index schemas
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ generated/               # Synthetic test data
โ”‚   โ””โ”€โ”€ reports/                 # Audit output (markdown)
โ”œโ”€โ”€ docs/
โ”‚   โ””โ”€โ”€ kibana_setup.md          # Step-by-step Kibana configuration
โ”œโ”€โ”€ orchestrator/
โ”‚   โ”œโ”€โ”€ a2a_client.py            # A2A protocol client
โ”‚   โ””โ”€โ”€ run_audit.py             # Main orchestrator script
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ generate_synthetic_data.py
โ”‚   โ””โ”€โ”€ ingest.py
โ”œโ”€โ”€ ui/
โ”‚   โ”œโ”€โ”€ app.py                   # Flask dashboard
โ”‚   โ””โ”€โ”€ templates/index.html
โ”œโ”€โ”€ .env.example
โ”œโ”€โ”€ LICENSE (MIT)
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ requirements.txt

๐Ÿš€ Quickstart

Prerequisites

1. Install

git clone https://github.com/N-45div/PassedAI.git
cd PassedAI
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env

2. Configure .env

Variable Source
ELASTIC_CLOUD_ID Elastic Cloud โ†’ Project โ†’ Manage โ†’ Cloud ID
ELASTIC_API_KEY Elastic Cloud โ†’ API Keys โ†’ Create
KIBANA_BASE_URL Derived from Cloud ID (see docs)
KIBANA_API_KEY Kibana โ†’ Stack Management โ†’ API Keys
PASSED_DETECT_AGENT_ID After creating agent in Kibana
PASSED_ACT_AGENT_ID After creating agent in Kibana

3. Generate & Ingest Data

python scripts/generate_synthetic_data.py
python scripts/ingest.py --reset

4. Configure Kibana

Follow docs/kibana_setup.md:

  1. Verify ELSER v2 is running
  2. Create 4 ES|QL tools
  3. Create PassedAI-Detect and PassedAI-Act agents
  4. Copy agent IDs to .env

5. Run Audit

python orchestrator/run_audit.py --audit-window-days 90 --top-n-actions 10

6. View Dashboard

python ui/app.py
# Open http://localhost:5050

๐Ÿ”ง How It Works

Detect Phase

The PassedAI-Detect agent runs 4 ES|QL queries in sequence:

  1. staleness_scorer โ€” Finds docs with staleness_score >= 70
  2. gap_detector โ€” Finds unanswered questions (knowledge gaps)
  3. contradiction_finder โ€” Semantic search for conflicting docs on same topic
  4. expert_risk_finder โ€” Aggregates doc ownership to find concentration risk

Act Phase

The PassedAI-Act agent processes findings and outputs structured action logs:

ACTION | notify_owner | doc_id=abc123 | owner=alice@acme.io | issue=stale | score=100
ACTION | notify_owner | topic=data-retention | issue=contradiction | docs=doc1,doc2

Orchestrator

The Python orchestrator (run_audit.py):

  1. Sends audit prompt to Detect agent via A2A
  2. Parses structured findings
  3. Sends findings to Act agent via A2A
  4. Writes markdown report to data/reports/

๐Ÿ“ Challenges & Learnings

  1. A2A Protocol Discovery โ€” Elastic Agent Builder uses message/send method with kind: "text" parts (not type). Required debugging the JSON-RPC format.

  2. Serverless ES Restrictions โ€” Index mappings can't include number_of_shards / number_of_replicas settings. Had to remove these for Serverless compatibility.

  3. ELSER Inference Timeouts โ€” Bulk ingestion with semantic_text fields requires longer timeouts (120s) and smaller chunk sizes (10 docs) due to inference processing time.


๐Ÿ“œ License

MIT License โ€” see LICENSE


๐Ÿ™ Acknowledgments

Built with:


Built for the Elasticsearch Agent Builder Hackathon ๐Ÿ†

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors