Skip to content

sydasif/network-automation-agent

Repository files navigation

Network AI Agent Logo

Network AI Agent

A powerful, AI-driven tool for seamless network automation and management.

A lightweight, "Human-in-the-Loop" AI agent that translates natural language into network configuration and show commands. Built with LangGraph, Nornir, and Chainlit.

🚀 Quick Start (Docker)

The easiest way to run the agent is using Docker. This ensures a consistent environment.

1. Setup

git clone https://github.com/yourusername/network-agent.git
cd network-agent

2. Configuration

Create your secrets and inventory files.

.env (Secrets):

GROQ_API_KEY=gsk_your_api_key_here

hosts.yaml (Inventory):

---
sw1:
  hostname: 192.168.1.10
  groups: [cisco]
sw2:
  hostname: 192.168.1.11
  groups: [cisco]

groups.yaml (Platform Definitions):

---
cisco:
  platform: cisco_ios
  username: admin
  password: admin

arista:
  platform: arista_eos
  username: admin
  password: admin

3. Run

docker compose up --build

Access the Web UI at http://localhost:8000


🏗️ Architecture

The project follows a flattened, KISS architecture leveraging Nornir for parallel execution:

Component File Purpose
Brain agent/ LangGraph workflow, prompts, and decision routing.
Hands tools/ Split into show.py (Read) and config.py (Write).
Engine utils/devices.py Nornir initialization and task execution engine.
UI app.py Chainlit Web Interface.
CLI main.py Terminal entry point.

Key Features

  1. Parallel Execution:
    • Uses Nornir to execute read-only commands (show version) on hundreds of devices simultaneously.
  2. Safety First:
    • Sequential Configs: Configuration changes are handled sequentially with a Human-in-the-Loop approval step for every batch.
    • The Agent cannot execute changes without your explicit "Yes".
  3. Smart Input Sanitization:
    • Automatically cleans up LLM outputs (e.g., stripping markdown code blocks from config sets) before sending to devices.
  4. Structured Output:
    • Uses TextFSM (via ntc-templates) to parse raw CLI output into structured JSON data for the LLM.

🛠️ Local Development

If you prefer running without Docker:

  1. Install Dependencies:

    # Using uv (Recommended)
    uv sync
    # Or standard pip
    pip install -r requirements.txt
  2. Run Web UI:

    chainlit run app.py -w
  3. Run CLI:

    python main.py "Show ip int brief on sw1"

📚 Tools & Modules

  • agent.nodes: Defines the graph state and interaction logic.
  • utils.devices: Lazy-loads Nornir and injects secrets from environment variables.
  • tools.show: Wraps nornir_netmiko.netmiko_send_command.
  • tools.config: Wraps nornir_netmiko.netmiko_send_config.

🤝 Contributing

  1. Fork the repo
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

About

Run commands on network device with LLM using netmiko

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •