Skip to content

Repository files navigation

GridGuard Strands Operations Autopilot

Autonomous grid-operations triage · Human-governed decisions · Immutable audit trail
AWS "Agents for Humans" Hackathon — Professional Agents Track

Python 3.11+ Strands Agents SDK License: MIT MOCK_MODE


Hackathon Alignment: Strands First, Bedrock Ready

  • Strands Agents SDK is the core of GridGuard. It orchestrates the eight-step grid-operations workflow, tool calls, human approval gate, and audit trail.
  • Amazon Bedrock is the configurable live-model path. When MOCK_MODE=false, the Strands agent can generate a bounded, evidence-grounded operator briefing using Amazon Nova Lite, with Nova Micro as a lower-cost fallback.
  • Groq is an optional secondary live demo path (via the Strands OpenAI-compatible model adapter). It requires a four-factor gate: MOCK_MODE=false, LIVE_LLM_ENABLED=true, STRANDS_PROVIDER=groq, and a non-empty GROQ_API_KEY. It is not Bedrock, AgentCore, or an AWS-hosted model.
  • Mock mode is the default safe demonstration profile. The full deterministic workflow remains reviewable with zero cloud-model calls or credentials.
  • Railway is the intended public-hosting path for the Streamlit dashboard. The public Railway deployment uses the Groq provider for the optional, bounded live operator briefing. Bedrock is not active in the public deployment.
  • AWS Lambda is optional deployment evidence. It demonstrates a separately deployed internal action handler and successful CloudFormation/Lambda smoke test; it is not the full GridGuard application or full AgentCore Runtime deployment.

What It Does

Grid and utility operations teams spend significant time repeatedly triaging risk signals, checking runbooks, creating mitigation recommendations, and preparing work orders. GridGuard Strands Operations Autopilot is an autonomous-but-human-governed agent that handles this repetitive structured work — and only escalates when an operator decision is needed.

The agent ingests a simulated grid-risk event (severe weather, rising demand, equipment risk, or outage warning), runs a structured eight-step workflow through Strands tool functions, and surfaces every decision in a clean Streamlit dashboard — including a mandatory human approval gate before any action becomes active.

⚠️ Safety Boundary: This system operates entirely on synthetic/simulated data. It does not connect to, monitor, or control any real electric grid, generation asset, transmission infrastructure, or customer load. All drafted actions are recommendations; a human operator makes every final decision.


Architecture

GridGuard architecture diagram

GridGuard is publicly deployed as a Streamlit dashboard on Railway. The AWS Strands Agents SDK orchestrates the core eight-stage workflow.

  • Deterministic Pipeline: The XGBoost demand forecast, runbook retrieval, risk assessment, mitigation plan generation, mandatory human approval gate, and immutable audit trail all execute deterministically.
  • Live LLM Briefing: The deployment uses the Groq provider for an optional, bounded live operator briefing (openai/gpt-oss-20b). Note that Groq is not Amazon Bedrock or AgentCore.
  • Safe Fallback: When MOCK_MODE=true, GridGuard runs the exact same workflow deterministically with zero LLM API calls.
  • Safety Boundary: The application relies exclusively on synthetic data and does not monitor or control any real electrical grid.

Quick Start (Local Demo — No API Keys Needed)

Prerequisites

  • Python 3.11+
  • pip or uv

1. Clone & Install

git clone https://github.com/draculess99/GridGuard-Strands-Autopilot.git
cd GridGuard-Strands-Autopilot
pip install -e ".[dev]"

2. Configure environment

cp .env.example .env
# No changes needed for MOCK_MODE demo — leave MOCK_MODE=true

3. Run the CLI demo

python scripts/run_demo.py                          # SEVERE_WEATHER scenario
python scripts/run_demo.py --scenario HIGH_DEMAND   # High demand scenario
python scripts/run_demo.py --scenario EQUIPMENT_RISK --approve  # auto-approve

4. Run the Streamlit dashboard

streamlit run dashboard/app.py

Open http://localhost:8501 — select a scenario, click Run Agent Workflow, then use the Approve / Reject buttons.

5. Run tests

pytest tests/ -v --tb=short

Expected: all 71 tests pass with zero cloud credentials.


Workflow Steps

# Step Tool Description
1 Grid Snapshot get_grid_snapshot Retrieves current demand, capacity, reserve, frequency for the region
2 Demand Forecast forecast_demand_xgboost 24-hour ML forecast: peak MW, reserve margin %, high-risk hours
3 Runbook retrieve_runbook Fetches the relevant standard operating procedure
4 Risk Assessment assess_risk Scores severity 1–5 using current telemetry and XGBoost forecast impact
5 Mitigation Plan generate_mitigation_steps Generates ordered, role-assigned action steps from the runbook catalogue
6 Work Order draft_work_order Formats a structured DRAFT work order document
7 ⚠️ HITL Gate request_human_approval Mandatory — suspends until operator Approves or Rejects
8 Audit Record record_audit_event Writes SHA-256-hashed immutable record to data/audit_log.jsonl

Dashboard Sections

  1. Ingested Event — event title, description, ID, severity badge
  2. Strands Backend Panel — displays active orchestration, provider, primary model, fallback model, and mock/live status in the sidebar
  3. Workflow Timeline — all 8 steps with status badges and elapsed time
  4. Risk Assessment — severity gauge, load factor, reserve margin, and explicit XGBoost forecast impact
  5. XGBoost Forecast — peak demand, available capacity, projected reserve margin, and hourly trajectory chart
  6. Grid Snapshot — regional telemetry at-a-glance
  7. Mitigation Plan — ordered step cards with responsible roles and timeframes
  8. Work Order Draft — structured document with Approve / Reject HITL buttons
  9. Operational Runbook — full runbook for the event type
  10. Audit Trail — paginated immutable event log with SHA-256 hash display

Demo Scenarios

Scenario Description Default Severity
SEVERE_WEATHER Ice storm approaching — demand surge expected HIGH (4/5)
HIGH_DEMAND Load approaching N-1 contingency threshold HIGH (4/5)
EQUIPMENT_RISK Transformer DGA alert — Health Index < 0.65 MEDIUM (3/5)
OUTAGE_WARNING Scheduled maintenance conflict — N-1 violation risk MEDIUM (3/5)

Project Structure

GridGuard-Strands-Autopilot/
├── gridguard/
│   ├── agent.py                # Strands Agent + mock workflow engine
│   ├── config.py               # Pydantic-settings configuration
│   ├── logger.py               # Structured JSON logger
│   ├── data/
│   │   ├── synthetic_events.py # Canonical event generator
│   │   └── runbooks.py         # Static runbook store
│   ├── models/
│   │   └── xgboost_demand_model.json # Serialized XGBoost model artifact
│   └── tools/
│       ├── grid_snapshot.py    # get_grid_snapshot()
│       ├── forecast.py         # forecast_demand_xgboost()  ← ML forecaster
│       ├── runbook.py          # retrieve_runbook()
│       ├── risk_assessor.py    # assess_risk()
│       ├── mitigation.py       # generate_mitigation_steps()
│       ├── work_order.py       # draft_work_order()
│       ├── human_approval.py   # request_human_approval()  ← HITL gate
│       └── audit.py            # record_audit_event()
├── dashboard/
│   └── app.py                  # Streamlit dashboard
├── scripts/
│   └── run_demo.py             # Rich CLI demo runner
├── tests/
│   ├── conftest.py
│   ├── test_tools.py           # 30+ unit tests (including XGBoost)
│   ├── test_workflow.py        # Integration tests (all 4 scenarios)
│   └── test_audit.py           # Audit trail tests
├── .github/workflows/
│   └── ci.yml                  # GitHub Actions CI (Python 3.11 / 3.12)
├── .env.example
├── pyproject.toml
└── README.md

Configuration Reference

Variable Default Description
MOCK_MODE true true = full demo, zero cloud calls. false = live Bedrock briefing mode.
STRANDS_PROVIDER bedrock Active provider: bedrock or anthropic
AWS_REGION us-east-1 AWS region for Amazon Bedrock
BEDROCK_MODEL_ID amazon.nova-lite-v1:0 Active, AWS-native, cost-conscious Bedrock model (fully configurable)
BEDROCK_FALLBACK_MODEL_ID amazon.nova-micro-v1:0 Cheaper fallback Bedrock model if the primary model fails
LIVE_RUN_LIMIT 5 Process-level ceiling on live calls to prevent runaway spend
LIVE_MAX_OUTPUT_TOKENS 600 Concise output token cap on model briefings
LIVE_TEMPERATURE 0.2 Sampling temperature for deterministic briefing
ANTHROPIC_API_KEY (empty) Optional: Required only if STRANDS_PROVIDER=anthropic
AUDIT_LOG_PATH data/audit_log.jsonl Append-only audit log path
LOG_LEVEL INFO Structured JSON log level

Railway Deployment Configuration

GridGuard is publicly deployed on Railway and supports two clear modes:

  • an optional live Groq-backed operator-briefing path through the Strands Agents SDK;
  • a deterministic synthetic mock fallback.
# Optional live Groq operator briefing on Railway
MOCK_MODE=false
LIVE_LLM_ENABLED=true
STRANDS_PROVIDER=groq
GROQ_MODEL_ID=openai/gpt-oss-20b
GROQ_API_KEY=your_groq_api_key_here
# Deterministic synthetic workflow — zero LLM API calls
MOCK_MODE=true

Configuration Notes:

  • GROQ_API_KEY is configured privately in Railway Variables and must never be committed to GitHub, shown in screenshots, or placed in a URL.
  • In live mode, Groq generates only the bounded operator briefing.
  • The grid scenarios, forecast inputs, XGBoost forecast, workflow steps, mitigation plan, human approval gate, and audit trail remain synthetic/deterministic and safety-governed.
  • With MOCK_MODE=true, GridGuard uses the deterministic synthetic workflow and makes zero Groq, Bedrock, or other LLM API calls.
  • The mock path is the safe, reproducible, no-model-spend fallback for reviewers and local development.
  • Groq is not Amazon Bedrock or AgentCore, and GridGuard does not control a real electrical grid.
  • Amazon Bedrock remains configurable, but is not active in the public deployment while the account-level Bedrock Runtime access issue is unresolved.

Safe, Bounded Live Amazon Bedrock Mode

When MOCK_MODE=false, GridGuard uses a real Strands Agent backed by Amazon Bedrock to generate an evidence-grounded Operator Briefing.

Cost & Safety Safeguards

  1. Zero Retries / Single Invocation: The briefing agent is bounded to exactly 1 turn (Limits(turns=1, output_tokens=600)) with zero retries (ModelRetryStrategy(max_attempts=1)). No background polling, loops, memory storage, or external searches.
  2. Process-Level Run Limit: Governed by LIVE_RUN_LIMIT=5 (configurable). Once reached, the application locks out further live calls until restart.
  3. Dashboard Authorization Gate: Before any live Bedrock request is executed from the Streamlit UI, the operator must explicitly check the confirmation box: "I confirm I want to call Amazon Bedrock".
  4. Deterministic Authority: The LLM cannot modify XGBoost forecast numbers, risk severity scores, mitigation steps, work order numbers, or the approval gate. All governance remains 100% deterministic in Python.
  5. Secret Redaction: AWS secret keys, access keys, and tokens are automatically scrubbed from structured JSON logs.
  6. Graceful Fallback: If Bedrock is throttled, unavailable, or credentials fail, the workflow continues deterministically without bypassing human approval or corrupting audit integrity.

Configuring Your First Live Run

  1. Ensure model access is enabled for amazon.nova-lite-v1:0 (or your chosen model) in your AWS region (e.g. us-east-1 or us-west-2).
  2. Create your .env file:
    MOCK_MODE=false
    STRANDS_PROVIDER=bedrock
    AWS_REGION=us-east-1
    AWS_ACCESS_KEY_ID=AKIA...
    AWS_SECRET_ACCESS_KEY=...
    # Default active cost-conscious model, or specify any active Bedrock model
    BEDROCK_MODEL_ID=amazon.nova-lite-v1:0
    BEDROCK_FALLBACK_MODEL_ID=amazon.nova-micro-v1:0
    LIVE_RUN_LIMIT=5
  3. Run the dashboard or CLI demo:
    streamlit run dashboard/app.py
    # Or run via CLI:
    python scripts/run_demo.py --scenario SEVERE_WEATHER --approve

Safety Boundaries

  1. Synthetic data only — All grid data, asset IDs, and scenarios are fabricated.
  2. No real infrastructure — The system has no connection to any operational technology (OT), SCADA, EMS, or DMS.
  3. Human approval mandatory — No drafted action can proceed without explicit operator approval via the request_human_approval tool.
  4. Immutable audit trail — Every decision is recorded with a SHA-256 content hash.
  5. Clearly labelled — All tool outputs include data_source: SYNTHETIC_DEMO.

Prior Work Disclosure

This project was built during the AWS Agents for Humans Hackathon submission period.

  • Originating Prior Work: The XGBoost demand forecasting pipeline (19 autoregressive/cyclical features, recursive multi-step forecasting, and hyperparameter configuration) and synthetic grid-domain assumptions originate from the author's earlier GridGuard AI exploration.
  • New Work Built for This Hackathon: The entire agentic system and AWS-ready architecture are genuinely new and built specifically for this submission:
    • Strands Agents SDK integration with typed @tool registry
    • 8-step autonomous-but-human-governed workflow
    • Deterministic zero-token mock workflow engine
    • Non-skippable Human-in-the-Loop (HITL) approval gate
    • Streamlit operations dashboard with forecast trajectory chart and risk explanation
    • Configurable mock and live Bedrock modes (Nova Lite / Nova Micro fallback)
    • Append-only SHA-256 tamper-evident JSONL audit trail
    • GitHub Actions multi-version CI pipeline (Python 3.11 / 3.12)
    • 71-test automated test suite (100% passing offline without credentials)

Evidence Walkthrough

GridGuard is demonstrated as a complete, human-governed grid-operations workflow. The screenshots below show the product experience first, then the automated test evidence, and finally the optional AWS deployment evidence.

1. Safe, configurable Strands agent

GridGuard uses the AWS Strands Agents SDK to orchestrate its workflow. The dashboard makes the active provider, primary/fallback Bedrock model configuration, and MOCK_MODE status visible. The public demo defaults to offline mock mode, so it can be reviewed without cloud-model cost or credentials.

Strands backend configuration

2. Tested before deployment

The project has 71 passing offline tests. This provides regression evidence for the deterministic workflow, safety controls, approval behavior, and audit handling before any cloud integration is considered.

71 offline tests passing

3. End-to-end human-governed workflow

A simulated severe-weather grid event moves through the eight-step workflow: grid snapshot, demand forecast, runbook retrieval, risk assessment, mitigation planning, work-order drafting, mandatory human approval, and audit recording. The system is synthetic-only; it does not control real grid infrastructure.

Approved GridGuard workflow and audit record

Public Railway Deployment Walkthrough

GridGuard is publicly deployed as a Streamlit dashboard on Railway: https://gridguard-strands-autopilot-production.up.railway.app. Railway hosts the reviewer-facing dashboard; it does not replace the Strands agent architecture.

  • Live LLM Path: The live optional LLM path uses Groq through the Strands Agents SDK, with model openai/gpt-oss-20b. In live Groq mode, Railway privately stores the Groq API key; no API key is committed to GitHub or displayed in the application. Groq generates the bounded operator briefing only. The grid-risk scenarios, forecast inputs, workflow steps, mitigation plan, human approval, and audit trail remain synthetic/deterministic and safety-governed. Groq is not Bedrock, AgentCore, or an AWS-hosted model, and it does not control a real grid.
  • Safe Fallback: When MOCK_MODE=true, GridGuard runs the deterministic synthetic workflow with zero Groq, Bedrock, or other LLM API calls. This mock mode remains the safe, reproducible, no-model-spend fallback.
  • Amazon Bedrock: Amazon Bedrock is configurable but currently not used by the public demo because account-level runtime access remains unavailable.

1. Live dashboard ready

The Railway URL loads the public GridGuard dashboard and allows a reviewer to select a synthetic grid-risk scenario. It identifies the approver for audit purposes and explicitly displays that the safe mock mode is active.

Live Railway dashboard ready

2. Complete human-governed workflow

The public workflow successfully completed all eight Strands-orchestrated steps: grid snapshot, XGBoost demand forecast, runbook retrieval, risk assessment, mitigation planning, work-order drafting, the human approval gate, and the audit record. The work order is approved only after the named Shift Manager explicitly authorizes it, at which point an audit record is written.

Railway workflow approved

3. Forecast evidence

The XGBoost forecast compares predicted demand with available capacity, highlighting the reserve margin and high-risk hours to provide evidence for the mitigation recommendation. This is a synthetic demonstration forecast, not a live electrical-grid feed.

Railway XGBoost forecast

4. Approved decision and immutable audit trail

The completed public workflow safely records the approval decision, approver identity, work-order reference, and workflow-completed events into the immutable audit trail. This emphasizes that GridGuard is strictly human-governed: it drafts recommendations and work orders but does not perform real-world grid control.

Railway forecast and audit trail

This public Railway deployment is the intended reviewer-facing application. As noted above, Amazon Bedrock remains a configurable live-model path when MOCK_MODE=false and AWS credentials are supplied privately, but is currently not used. The separate AWS Lambda/CloudFormation smoke-test evidence documents an optional internal action-handler deployment proof, not the public website and not a full AgentCore Runtime deployment.

5. Optional AWS Lambda deployment proof — separate from the application runtime

GridGuard’s normal Strands workflow does not depend on this Lambda. This small internal AWS Lambda handler was deployed separately through CloudFormation to demonstrate an AWS deployment component: infrastructure packaging, IAM execution-role configuration, and a structured request/response smoke test.

It is not a public website, public API, full GridGuard deployment, or full AgentCore Runtime deployment. Deleting this optional stack does not affect the local dashboard or a future Railway-hosted dashboard.

The CloudFormation Console confirms that the stack gridguard-strands-agentcore-smoke reached UPDATE_COMPLETE and deployed both the Lambda function and its IAM role.

AWS CloudFormation Lambda resources updated successfully

The deployed Lambda was then invoked with a structured smoke-test event. It returned StatusCode: 200, no FunctionError, and a structured mock-mode response.

AWS Lambda action-group smoke test successful

Deployment relationship

  • Railway is the intended public-hosting path for the Streamlit dashboard, optionally using Groq for the live briefing.
  • Mock mode is the default safe, reproducible, no-model-spend fallback with zero Groq, Bedrock, or other LLM API calls.
  • Amazon Bedrock is configurable but currently not used by the public demo because account-level runtime access remains unavailable.
  • AWS Lambda is optional internal deployment evidence and can be deleted after submission without affecting Railway.

License

MIT — see LICENSE.

About

Autonomous grid-operations triage with human-governed decisions and an immutable audit trail — built with the AWS Strands Agents SDK.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages