Skip to content

shivamsingh-007/SCOUT-The-Agentic-Loop

Repository files navigation

SCOUT Logo

SCOUT

Evidence-Grounded Agentic Loop Platform

Python 3.11+ Tests mypy Ruff License Ollama


Every claim traces to evidence. If evidence is missing, SCOUT says so β€” it doesn't guess.

πŸš€ Runs with Llama 3 locally via Ollama β€’ πŸ“Š Real-time evidence tracking β€’ πŸ”’ Tenant-safe from day one


✨ What is SCOUT?

SCOUT is a production-grade single-agent runtime that proves its answers. Every tool output becomes evidence. Every claim is validated. Every answer is grounded.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                                                             β”‚
β”‚   User Query β†’ Tool Calls β†’ Evidence Pool β†’ Grounded Answer β”‚
β”‚       β”‚              β”‚           β”‚                β”‚         β”‚
β”‚       β–Ό              β–Ό           β–Ό                β–Ό         β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚   β”‚ Task │────▢│ LLM Call │─▢│ Score  │────▢│ Verifiedβ”‚   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🎯 Why SCOUT?

The Problem With Toy Agents

Most LLM agent frameworks give you a response and a prayer. They call tools, build context, and produce answers β€” but you have no way to prove why they're trustworthy.

The gap between "it runs" and "it's reliable" is where production agents die.

The SCOUT Solution

Problem SCOUT Solution
Hallucinated citations Evidence validation against actual pool
Fabricated data 5-tier grounding quality scoring
Unbounded loops Typed state machine with budgets
Provider failures Multi-provider fallback with fault injection
Multi-tenant security Tenant isolation (404 on cross-tenant)

πŸ—οΈ Architecture

System Overview

flowchart TB
    A[Client Request] --> B[Auth Middleware]
    B --> C[Rate Limiter]
    C --> D[Run Service]
    D --> E[Loop Controller]
    E --> F[Planner]
    E --> G[Executor]
    E --> H[Stop Controller]
    G --> I[Evidence Store]
    I --> J[Citation Parser]
    J --> K[Grounding Validator]
    F --> L[Primary Provider]
    L -->|fail| M[Fallback Provider]
Loading

Grounding Pipeline

flowchart LR
    A[Tool Output] --> B[EvidenceRecord]
    B --> C[Content Hash]
    B --> D[Source Reference]
    C --> E[Score]
    D --> E
    E --> F[Citation Parser]
    F --> G[Grounding Quality]
    G --> H[Final Answer]
Loading

Provider Fallback Flow

flowchart TD
    A[LLM Call] --> B{Primary Provider}
    B -->|Success| C[Response]
    B -->|Rate Limit| D[Retry with Jitter]
    B -->|Error| E[Fallback Manager]
    D -->|Success| C
    D -->|Exhausted| E
    E -->|Success| C
    E -->|All Failed| F[Output Repair]
    F --> G[Final Response]
Loading

πŸš€ Quick Start

Prerequisites

  • Python 3.11+
  • Ollama (for local LLM)

Installation

# Clone the repository
git clone https://github.com/shivamsingh-007/SCOUT-The-Agentic-Loop.git
cd SCOUT-The-Agentic-Loop

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate

# Install dependencies
pip install -e ".[dev]"

First Run

# Pull Llama 3 model
ollama pull llama3

# Run tests
pytest -q

# Start API server
uvicorn scout.api.app:create_app --factory --reload

# Create a run
curl -X POST http://localhost:8000/v1/runs \
  -H "Content-Type: application/json" \
  -d '{"task": "What is the capital of France?"}'

πŸ“Š Features

πŸ” Evidence Grounding

Every tool output becomes evidence with:

  • Content hashes for deduplication
  • Source references for provenance
  • Composite scoring (relevance + recency + quality)

πŸ“ˆ 5-Tier Grounding Quality

Tier Description Action
🟒 Strong Multiple strong citations Proceed
🟑 Adequate Basic citations present Proceed with note
🟠 Weak Limited evidence Flag for review
πŸ”΄ Speculative Inconsistent evidence Reject
⚫ None No evidence Reject

πŸ”„ Multi-Provider Fallback

Primary Provider β†’ Retry β†’ Fallback β†’ Output Repair
       ↓              ↓         ↓           ↓
    Success      Success    Success     Final Answer

πŸ”’ Security Features

  • HMAC-based auth with constant-time comparison
  • Per-tenant rate limiting (requests/min, requests/hour)
  • Tenant isolation (404 on cross-tenant access)
  • Error sanitization (no file paths or API keys in errors)
  • Graceful shutdown with database cleanup

πŸ§ͺ Quality Gates

Metric Value Status
Tests 628 passing βœ…
Type Checking mypy strict, 0 errors βœ…
Linting Ruff, 0 errors βœ…
API Isolation Tenant-safe (404) βœ…
Auth Constant-time + HMAC βœ…
Storage SQLite hardened βœ…

πŸ“ˆ Eval Results

Unit Tests (Mocked)

Metric Result
Test Pass Rate 100%
mypy Errors 0
Ruff Errors 0

Live Ollama Runs

Metric Result
Tasks Run 10/10
Parse Success 100%
Citation Validity 70%
Avg Latency 13.3s

πŸ—‚οΈ Project Structure

src/scout/
β”œβ”€β”€ api/               # FastAPI server, auth, rate limiting
β”‚   β”œβ”€β”€ routers/       # API endpoints
β”‚   β”œβ”€β”€ services/      # Business logic
β”‚   └── utils.py       # Error sanitization
β”œβ”€β”€ runtime/           # State machine, loop controller
β”‚   β”œβ”€β”€ agent.py       # Main agent class
β”‚   β”œβ”€β”€ loop.py        # Loop controller
β”‚   └── verifier.py    # Grounding verification
β”œβ”€β”€ llm/               # LLM provider abstraction
β”‚   β”œβ”€β”€ ollama.py      # Ollama provider
β”‚   β”œβ”€β”€ router.py      # Provider routing
β”‚   └── fallback.py    # Fallback logic
β”œβ”€β”€ tools/             # Tool protocol and implementations
β”œβ”€β”€ grounding/         # Evidence tracking and scoring
β”‚   β”œβ”€β”€ scorer.py      # BM25 scoring
β”‚   └── validator.py   # Claim validation
β”œβ”€β”€ memory/            # SQLite memory store
└── config.py          # Typed configuration

πŸ› οΈ Development

Commands

# Run all tests
make test

# Run linting
make lint

# Run type checking
make typecheck

# Run all quality gates
make all

# Start development server
make serve

Code Style

  • Ruff for linting and formatting
  • mypy strict mode for type checking
  • Pydantic v2 for data validation
  • pytest for testing

πŸ—ΊοΈ Roadmap

Phase Status Description
Phase 1-10 βœ… Complete Core platform
Phase 11 πŸ”„ In Progress Eval framework
Phase 12 πŸ“‹ Planned Dashboard UI
Phase 13 πŸ“‹ Planned Multi-provider
Phase 14 πŸ“‹ Planned Persistent memory

🀝 Contributing

See CONTRIBUTING.md for the full process.

# Quick start
git checkout -b feat/my-feature
make all
git commit -m "feat: add new feature"
git push origin feat/my-feature

πŸ“„ License

MIT License - see LICENSE


πŸ”— Links


Built with ❀️ by Shivam Singh

GitHub

About

No description, website, or topics provided.

Resources

License

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors