Analysis Agent¶
The Analysis Agent is a pure-computation engine for routing analysis, What-If simulation, and topology visualization. It runs entirely in an isolated sandbox β no network access, no device connections.
Feature Claims
| ID | Claim | Status |
|---|---|---|
| C-NE-22 | What-If simulation: disabling a link recalculates connectivity and blast radius | πΆ Env-Blocked |
| C-NE-23 | Analysis Agent uses only run_python_simulation β no live device access |
β¬ Pending |
One Tool, Full Power¶
Analysis has a single tool: run_python_simulation. Inside this sandbox, the agent writes Python code with access to:
| Global | Type | Purpose |
|---|---|---|
db |
DatabaseProxy | db.query(sql) β read-only access to production snapshot data |
sim |
SimulationProxy | sim.clone(tables) then sim.execute(sql) β writable in-memory copy for mutations |
nx |
networkx | Graph engine: DiGraph, shortest_path, connected_components, has_path |
netutils |
netutils | IP math: subnet overlap, interface normalization, prefix calculations |
json, math, itertools, collections |
stdlib | Standard utilities |
The sandbox enforces network_isolation=True β no HTTP calls, no socket connections.
Use Cases¶
Routing Analysis¶
"Which BGP neighbors on R1 are not established?"
The agent queries v_bgp_neighbors_auto via db.query() and returns a filtered table.
What-If Simulation¶
"What happens if R2 loses all links?"
The agent:
- Clones topology data:
sim.clone(['topology_links', 'ospf_neighbors', 'bgp_neighbors']) - Mutates:
sim.execute("UPDATE sim_topology_links SET link_status = 'down' WHERE source_device = 'R2'") - Builds a networkx graph from the mutated state
- Computes blast radius via
nx.connected_components() - Returns affected devices, lost paths, and protocol impact
Path Analysis¶
"What is the shortest OSPF path from R1 to R4?"
The agent builds a weighted graph from OSPF costs and runs nx.shortest_path() with cost weights.
Topology Visualization¶
"Draw the network topology"
The agent queries netops.topology_links, builds a networkx graph, and renders a Mermaid diagram with device states and interface labels.
Simulation Workflow¶
Every simulation follows this pattern:
# Step 1 β Check data coverage
coverage = db.query("""
SELECT 'topology_links' tbl, count(*) rows FROM netops.topology_links
UNION ALL SELECT 'bgp_neighbors', count(*) FROM v_bgp_neighbors_auto
""")
# Step 2 β Clone needed tables
sim.clone(['topology_links', 'ospf_neighbors', 'routes', 'bgp_neighbors'])
# Step 3 β Mutate for What-If scenario
sim.execute("UPDATE sim_topology_links SET link_status = 'down' WHERE source_device = ?", ['R2'])
# Step 4 β Build networkx graph
links = sim.execute("SELECT source_device, destination_device, link_status FROM sim_topology_links").fetchall()
G = nx.DiGraph()
for src, dst, status in links:
G.add_edge(src, dst, link_status=status)
# Step 5 β Analyze with active-only subgraph
active = [(u, v) for u, v, d in G.edges(data=True) if d['link_status'] == 'active']
G_active = G.edge_subgraph(active).copy()
# Step 6 β Return results
_result = {
"blast_radius": [list(c) for c in nx.connected_components(G_active.to_undirected())],
"isolated_devices": [n for n in G.nodes() if n not in G_active],
}
The agent always produces a Markdown report with: Current State, Simulation Scope, Impact Analysis, Change Plan, Verification Commands, and Risk Classification.