# abhi291712/agentshield-pa architecture

> Architecture diagram of the GitHub repository abhi291712/agentshield-pa, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhi291712/agentshield-pa
- Repository: https://github.com/abhi291712/agentshield-pa
- Video tour (about a minute): https://gitdiagram.com/abhi291712/agentshield-pa/video

## Overview

AgentShield is a security layer for a synthetic healthcare prior-authorization agent, not a model or decision system. A reviewer’s request reaches the Lambda handler and guarded pipeline, which checks kill switches and quota before a bounded agent session returns advisory output for human review; the pipeline audits outcomes and handles failures. Separate security capabilities cover identity, policy, tool governance, retrieval, human approval, evaluation, incident response, readiness, and secure delivery. Source excerpts show the request path and several internal calls; other capability links rely on README descriptions, and unsampled implementation details are not asserted.

Main entry points: [`src/handler.py`](https://github.com/abhi291712/agentshield-pa/blob/main/src/handler.py) (API handler), [`src/pipeline.py`](https://github.com/abhi291712/agentshield-pa/blob/main/src/pipeline.py) (Guarded pipeline), [`src/mcp.py`](https://github.com/abhi291712/agentshield-pa/blob/main/src/mcp.py) (Tool plane), [`src/audit.py`](https://github.com/abhi291712/agentshield-pa/blob/main/src/audit.py) (Audit trail)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_request["Request and agent"]
  node_handler["API handler<br/>[handler.py]"]
  node_pipeline["Guarded pipeline<br/>[pipeline.py]"]
  node_agent["Agent session<br/>[agent.py]"]
  node_core["Direct review<br/>[core.py]"]
end

subgraph group_controls["Access and action controls"]
  node_identity["Identity tokens<br/>[identity.py]"]
  node_policy["Policy engine<br/>[policy.py]"]
  node_mcp["Tool plane<br/>[mcp.py]"]
  node_workflow["Human approvals<br/>[workflow.py]"]
end

subgraph group_evidence["Evidence and guardrails"]
  node_guardrails["Content guardrails<br/>[guardrails.py]"]
  node_memory[("Governed memory<br/>[memory.py]")]
  node_rag[("Governed retrieval<br/>[rag.py]")]
end

subgraph group_operations["Audit and operations"]
  node_audit[("Audit trail<br/>[audit.py]")]
  node_reliability["Reliability controls<br/>[reliability.py]"]
  node_observability["Observability<br/>[observability.py]"]
  node_incident["Incident response<br/>[incident.py]"]
end

subgraph group_assurance["Assurance and governance"]
  node_evals["Security evaluations<br/>[evals.py]"]
  node_delivery["Secure delivery<br/>[delivery.py]"]
  node_readiness["Readiness gate<br/>[readiness.py]"]
end

node_reviewer(("Reviewer"))
node_bedrock["Amazon Bedrock"]
node_dynamodb[("DynamoDB")]

node_reviewer -->|"submits request"| node_handler
node_handler -->|"routes agent request"| node_pipeline
node_handler -->|"routes review request"| node_core
node_handler -->|"invokes Converse"| node_bedrock
node_pipeline -->|"runs session"| node_agent
node_pipeline -->|"checks quota and classifies failures"| node_reliability
node_pipeline -->|"checks output"| node_guardrails
node_pipeline -->|"records request"| node_audit
node_pipeline -->|"checks kill switch"| node_incident
node_agent -->|"requests model turns"| node_bedrock
node_agent -.->|"uses delegated identity"| node_identity
node_agent -.->|"dispatches tools"| node_mcp
node_mcp -->|"checks authorization"| node_policy
node_mcp -->|"requires approval"| node_workflow
node_mcp -.->|"screens tool content"| node_guardrails
node_mcp -.->|"uses case data"| node_dynamodb
node_core -->|"sends bounded evidence"| node_bedrock
node_rag -->|"screens ingested text"| node_guardrails
node_memory -->|"uses content checks"| node_guardrails
node_handler -->|"reads case records"| node_dynamodb
node_handler -->|"configures audit sink"| node_audit
node_audit -->|"writes audit entries"| node_dynamodb
node_observability -->|"analyzes events"| node_audit
node_incident -->|"verifies audit trail"| node_audit
node_incident -->|"adds regression cases"| node_evals
node_evals -->|"evaluates defenses"| node_guardrails
node_delivery -->|"checks change boundaries"| node_core
node_readiness -.->|"gates readiness"| node_delivery

click node_handler "https://github.com/abhi291712/agentshield-pa/blob/main/src/handler.py"
click node_pipeline "https://github.com/abhi291712/agentshield-pa/blob/main/src/pipeline.py"
click node_agent "https://github.com/abhi291712/agentshield-pa/blob/main/src/agent.py"
click node_core "https://github.com/abhi291712/agentshield-pa/blob/main/src/core.py"
click node_identity "https://github.com/abhi291712/agentshield-pa/blob/main/src/identity.py"
click node_policy "https://github.com/abhi291712/agentshield-pa/blob/main/src/policy.py"
click node_mcp "https://github.com/abhi291712/agentshield-pa/blob/main/src/mcp.py"
click node_workflow "https://github.com/abhi291712/agentshield-pa/blob/main/src/workflow.py"
click node_guardrails "https://github.com/abhi291712/agentshield-pa/blob/main/src/guardrails.py"
click node_memory "https://github.com/abhi291712/agentshield-pa/blob/main/src/memory.py"
click node_rag "https://github.com/abhi291712/agentshield-pa/blob/main/src/rag.py"
click node_audit "https://github.com/abhi291712/agentshield-pa/blob/main/src/audit.py"
click node_reliability "https://github.com/abhi291712/agentshield-pa/blob/main/src/reliability.py"
click node_observability "https://github.com/abhi291712/agentshield-pa/blob/main/src/observability.py"
click node_incident "https://github.com/abhi291712/agentshield-pa/blob/main/src/incident.py"
click node_evals "https://github.com/abhi291712/agentshield-pa/blob/main/src/evals.py"
click node_delivery "https://github.com/abhi291712/agentshield-pa/blob/main/src/delivery.py"
click node_readiness "https://github.com/abhi291712/agentshield-pa/blob/main/src/readiness.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_handler,node_pipeline,node_agent,node_core,node_reviewer toneBlue
class node_identity,node_policy,node_mcp,node_workflow,node_dynamodb toneAmber
class node_guardrails,node_memory,node_rag toneMint
class node_audit,node_reliability,node_observability,node_incident toneRose
class node_evals,node_delivery,node_readiness,node_bedrock toneIndigo
```

## Components

### Request and agent

- [API handler](https://github.com/abhi291712/agentshield-pa/blob/main/src/handler.py): `src/handler.py`
- [Guarded pipeline](https://github.com/abhi291712/agentshield-pa/blob/main/src/pipeline.py): `src/pipeline.py`
- [Agent session](https://github.com/abhi291712/agentshield-pa/blob/main/src/agent.py): `src/agent.py`
- [Direct review](https://github.com/abhi291712/agentshield-pa/blob/main/src/core.py): `src/core.py`

### Access and action controls

- [Identity tokens](https://github.com/abhi291712/agentshield-pa/blob/main/src/identity.py): `src/identity.py`
- [Policy engine](https://github.com/abhi291712/agentshield-pa/blob/main/src/policy.py): `src/policy.py`
- [Tool plane](https://github.com/abhi291712/agentshield-pa/blob/main/src/mcp.py): `src/mcp.py`
- [Human approvals](https://github.com/abhi291712/agentshield-pa/blob/main/src/workflow.py): `src/workflow.py`

### Evidence and guardrails

- [Content guardrails](https://github.com/abhi291712/agentshield-pa/blob/main/src/guardrails.py): `src/guardrails.py`
- [Governed memory](https://github.com/abhi291712/agentshield-pa/blob/main/src/memory.py): `src/memory.py`
- [Governed retrieval](https://github.com/abhi291712/agentshield-pa/blob/main/src/rag.py): `src/rag.py`

### Audit and operations

- [Audit trail](https://github.com/abhi291712/agentshield-pa/blob/main/src/audit.py): `src/audit.py`
- [Reliability controls](https://github.com/abhi291712/agentshield-pa/blob/main/src/reliability.py): `src/reliability.py`
- [Observability](https://github.com/abhi291712/agentshield-pa/blob/main/src/observability.py): `src/observability.py`
- [Incident response](https://github.com/abhi291712/agentshield-pa/blob/main/src/incident.py): `src/incident.py`

### Assurance and governance

- [Security evaluations](https://github.com/abhi291712/agentshield-pa/blob/main/src/evals.py): `src/evals.py`
- [Secure delivery](https://github.com/abhi291712/agentshield-pa/blob/main/src/delivery.py): `src/delivery.py`
- [Readiness gate](https://github.com/abhi291712/agentshield-pa/blob/main/src/readiness.py): `src/readiness.py`

### Other components

- **Reviewer**
- **Amazon Bedrock**
- **DynamoDB**

## Connections

- Reviewer → API handler: submits request (evidence: `README.md`)
- API handler → Guarded pipeline: routes agent request (evidence: `src/handler.py`)
- API handler → Direct review: routes review request (evidence: `src/handler.py`)
- API handler → Amazon Bedrock: invokes Converse (evidence: `src/handler.py`)
- Guarded pipeline → Agent session: runs session (evidence: `src/pipeline.py`)
- Guarded pipeline → Reliability controls: checks quota and classifies failures (evidence: `src/pipeline.py`)
- Guarded pipeline → Content guardrails: checks output (evidence: `src/pipeline.py`)
- Guarded pipeline → Audit trail: records request (evidence: `src/pipeline.py`)
- Guarded pipeline → Incident response: checks kill switch (evidence: `src/handler.py`)
- Agent session → Amazon Bedrock: requests model turns
- Agent session → Identity tokens: uses delegated identity (evidence: `README.md`)
- Agent session → Tool plane: dispatches tools (evidence: `README.md`)
- Tool plane → Policy engine: checks authorization (evidence: `README.md`)
- Tool plane → Human approvals: requires approval (evidence: `README.md`)
- Tool plane → Content guardrails: screens tool content (evidence: `README.md`)
- Tool plane → DynamoDB: uses case data (evidence: `README.md`)
- Direct review → Amazon Bedrock: sends bounded evidence
- Governed retrieval → Content guardrails: screens ingested text (evidence: `src/rag.py`)
- Governed memory → Content guardrails: uses content checks (evidence: `src/memory.py`)
- API handler → DynamoDB: reads case records (evidence: `src/handler.py`)
- API handler → Audit trail: configures audit sink (evidence: `src/handler.py`)
- Audit trail → DynamoDB: writes audit entries (evidence: `src/audit.py`)
- Observability → Audit trail: analyzes events (evidence: `src/observability.py`)
- Incident response → Audit trail: verifies audit trail (evidence: `src/incident.py`)
- Incident response → Security evaluations: adds regression cases (evidence: `src/incident.py`)
- Security evaluations → Content guardrails: evaluates defenses (evidence: `README.md`)
- Secure delivery → Direct review: checks change boundaries (evidence: `src/delivery.py`)
- Readiness gate → Secure delivery: gates readiness (evidence: `README.md`)
