# shaswatabarua/agentops-guardian architecture

> Architecture diagram of the GitHub repository shaswatabarua/agentops-guardian, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shaswatabarua/agentops-guardian
- Repository: https://github.com/shaswatabarua/agentops-guardian

## Overview

AgentOps supervises scripted or Gemini-backed agents: a supervisor starts a run, the runner mediates each tool call through loop, trust, and injection controls, and records results for human oversight. The API and dashboard provide run controls; MCP exposes supervisor controls to MCP clients. SQLite persists run, step, and trust state, while optional OpenTelemetry exports traces. Major documented capabilities are represented; relationships for unsampled MCP and dashboard internals are limited to README evidence.

Main entry points: [`runner.py`](https://github.com/shaswatabarua/agentops-guardian/blob/main/runner.py) (Run Orchestrator), [`api.py`](https://github.com/shaswatabarua/agentops-guardian/blob/main/api.py) (Control API), [`agents.py`](https://github.com/shaswatabarua/agentops-guardian/blob/main/agents.py) (Scripted Agents), [`trust.py`](https://github.com/shaswatabarua/agentops-guardian/blob/main/trust.py) (Trust Policy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_oversight["Human Oversight"]
  node_control_api["Control API<br/>[api.py]"]
  node_dashboard["Live Dashboard<br/>[dashboard.html]"]
  node_mcp_tools["MCP Controls<br/>[mcp_server.py]"]
end

subgraph group_execution["Agent Execution"]
  node_runner["Run Orchestrator<br/>[runner.py]"]
  node_scripted_agents["Scripted Agents<br/>[agents.py]"]
  node_shop_tools["Shop Tools<br/>[agents.py]"]
  node_gemini_agent["Gemini Agent<br/>[llm_agent.py]"]
end

subgraph group_controls["Run Controls"]
  node_circuit_breaker["Circuit Breaker<br/>[breaker.py]"]
  node_semantic_detector["Semantic Loop Detector<br/>[semantic.py]"]
  node_injection_shield["Injection Shield<br/>[shield.py]"]
  node_trust_policy["Trust Policy<br/>[trust.py]"]
end

subgraph group_state_observability["State &amp; Observability"]
  node_sqlite_store[("SQLite State<br/>[store.py]")]
  node_telemetry["OpenTelemetry Export<br/>[telemetry.py]"]
end

node_supervisor(("Human Supervisor"))
node_mcp_client(("MCP Client"))
node_gemini_service["Gemini API"]
node_otlp_collector["OTLP Collector"]

node_supervisor -->|"controls runs"| node_control_api
node_control_api -->|"serves dashboard"| node_dashboard
node_supervisor -->|"uses controls"| node_mcp_tools
node_mcp_client -->|"invokes tools"| node_mcp_tools
node_control_api -->|"starts runs"| node_runner
node_control_api -->|"reads and updates"| node_sqlite_store
node_control_api -->|"requests trust data"| node_trust_policy
node_runner -->|"requests agent steps"| node_scripted_agents
node_runner -->|"dispatches tool calls"| node_shop_tools
node_scripted_agents -->|"yields tool calls"| node_runner
node_runner -->|"checks each step"| node_circuit_breaker
node_runner -->|"configures detector"| node_semantic_detector
node_runner -->|"scans tool results"| node_injection_shield
node_runner -->|"checks action policy"| node_trust_policy
node_runner -->|"reads and writes run state"| node_sqlite_store
node_runner -->|"records run spans"| node_telemetry
node_scripted_agents -->|"registers agent"| node_gemini_agent
node_gemini_agent -->|"sends requests"| node_gemini_service
node_trust_policy -->|"records trust events"| node_sqlite_store
node_telemetry -.->|"exports traces"| node_otlp_collector

click node_control_api "https://github.com/shaswatabarua/agentops-guardian/blob/main/api.py"
click node_dashboard "https://github.com/shaswatabarua/agentops-guardian/blob/main/dashboard.html"
click node_mcp_tools "https://github.com/shaswatabarua/agentops-guardian/blob/main/mcp_server.py"
click node_runner "https://github.com/shaswatabarua/agentops-guardian/blob/main/runner.py"
click node_scripted_agents "https://github.com/shaswatabarua/agentops-guardian/blob/main/agents.py"
click node_shop_tools "https://github.com/shaswatabarua/agentops-guardian/blob/main/agents.py"
click node_gemini_agent "https://github.com/shaswatabarua/agentops-guardian/blob/main/llm_agent.py"
click node_circuit_breaker "https://github.com/shaswatabarua/agentops-guardian/blob/main/breaker.py"
click node_semantic_detector "https://github.com/shaswatabarua/agentops-guardian/blob/main/semantic.py"
click node_injection_shield "https://github.com/shaswatabarua/agentops-guardian/blob/main/shield.py"
click node_trust_policy "https://github.com/shaswatabarua/agentops-guardian/blob/main/trust.py"
click node_sqlite_store "https://github.com/shaswatabarua/agentops-guardian/blob/main/store.py"
click node_telemetry "https://github.com/shaswatabarua/agentops-guardian/blob/main/telemetry.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_control_api,node_dashboard,node_mcp_tools,node_mcp_client toneBlue
class node_runner,node_scripted_agents,node_shop_tools,node_gemini_agent toneAmber
class node_circuit_breaker,node_semantic_detector,node_injection_shield,node_trust_policy,node_gemini_service toneMint
class node_sqlite_store,node_telemetry toneRose
class node_supervisor,node_otlp_collector toneIndigo
```

## Components

### Human Oversight

- [Control API](https://github.com/shaswatabarua/agentops-guardian/blob/main/api.py): `api.py`
- [Live Dashboard](https://github.com/shaswatabarua/agentops-guardian/blob/main/dashboard.html): `dashboard.html`
- [MCP Controls](https://github.com/shaswatabarua/agentops-guardian/blob/main/mcp_server.py): `mcp_server.py`

### Agent Execution

- [Run Orchestrator](https://github.com/shaswatabarua/agentops-guardian/blob/main/runner.py): `runner.py`
- [Scripted Agents](https://github.com/shaswatabarua/agentops-guardian/blob/main/agents.py): `agents.py`
- [Shop Tools](https://github.com/shaswatabarua/agentops-guardian/blob/main/agents.py): `agents.py`
- [Gemini Agent](https://github.com/shaswatabarua/agentops-guardian/blob/main/llm_agent.py): `llm_agent.py`

### Run Controls

- [Circuit Breaker](https://github.com/shaswatabarua/agentops-guardian/blob/main/breaker.py): `breaker.py`
- [Semantic Loop Detector](https://github.com/shaswatabarua/agentops-guardian/blob/main/semantic.py): `semantic.py`
- [Injection Shield](https://github.com/shaswatabarua/agentops-guardian/blob/main/shield.py): `shield.py`
- [Trust Policy](https://github.com/shaswatabarua/agentops-guardian/blob/main/trust.py): `trust.py`

### State & Observability

- [SQLite State](https://github.com/shaswatabarua/agentops-guardian/blob/main/store.py): `store.py`
- [OpenTelemetry Export](https://github.com/shaswatabarua/agentops-guardian/blob/main/telemetry.py): `telemetry.py`

### Other components

- **Human Supervisor**
- **MCP Client**
- **Gemini API**
- **OTLP Collector**

## Connections

- Human Supervisor → Control API: controls runs (evidence: `README.md`)
- Control API → Live Dashboard: serves dashboard (evidence: `README.md`)
- Human Supervisor → MCP Controls: uses controls (evidence: `README.md`)
- MCP Client → MCP Controls: invokes tools (evidence: `README.md`)
- Control API → Run Orchestrator: starts runs (evidence: `api.py`)
- Control API → SQLite State: reads and updates (evidence: `api.py`)
- Control API → Trust Policy: requests trust data (evidence: `api.py`)
- Run Orchestrator → Scripted Agents: requests agent steps (evidence: `runner.py`)
- Run Orchestrator → Shop Tools: dispatches tool calls (evidence: `runner.py`)
- Scripted Agents → Run Orchestrator: yields tool calls (evidence: `agents.py`)
- Run Orchestrator → Circuit Breaker: checks each step (evidence: `runner.py`)
- Run Orchestrator → Semantic Loop Detector: configures detector (evidence: `runner.py`)
- Run Orchestrator → Injection Shield: scans tool results (evidence: `runner.py`)
- Run Orchestrator → Trust Policy: checks action policy (evidence: `runner.py`)
- Run Orchestrator → SQLite State: reads and writes run state (evidence: `runner.py`)
- Run Orchestrator → OpenTelemetry Export: records run spans (evidence: `runner.py`)
- Scripted Agents → Gemini Agent: registers agent (evidence: `agents.py`)
- Gemini Agent → Gemini API: sends requests (evidence: `llm_agent.py`)
- Trust Policy → SQLite State: records trust events (evidence: `trust.py`)
- OpenTelemetry Export → OTLP Collector: exports traces (evidence: `telemetry.py`)
