Skip to content

Agent Mesh

Update scale test for endurance run

Antonio Ojeae22794d291e3
diff --git a/cmd/chaos-agent/agent.py b/cmd/chaos-agent/agent.py
index 816299c1..6512fb99 100644
--- a/cmd/chaos-agent/agent.py
+++ b/cmd/chaos-agent/agent.py
@@ -77,15 +77,18 @@ async def main():
agent = create_tool_calling_agent(llm, lc_tools, prompt_template)
# AgentExecutor runs the ReAct/Tool loop automatically!
- agent_executor = AgentExecutor(agent=agent, tools=lc_tools, verbose=True, max_iterations=10)
+ agent_executor = AgentExecutor(agent=agent, tools=lc_tools, verbose=True, max_iterations=500)
print(f"\n--- Starting Chaos Monkey Agent Loop ---")
print(f"Instruction: {args.prompt}\n")
try:
- result = await agent_executor.ainvoke({"input": args.prompt})
- print("\n--- Final Agent Result ---")
- print(result["output"])
+ # Wrap in a loop to run for a while
+ for i in range(5):
+ print(f"\n--- Iteration {i+1} ---")
+ result = await agent_executor.ainvoke({"input": args.prompt})
+ print("\n--- Final Agent Result ---")
+ print(result["output"])
except Exception as e:
print(f"Agent Loop crashed (this might be a successful chaos test!): {e}")
diff --git a/scripts/launch-microvms.sh b/scripts/launch-microvms.sh
index db0f2fa8..77af4dc5 100755
--- a/scripts/launch-microvms.sh
+++ b/scripts/launch-microvms.sh
@@ -21,7 +21,7 @@ for i in $(seq 1 $COUNT); do
# Start sam-box on the host, listening on a dedicated UDS for this VM
# The sam-box acts as the gateway to the mesh.
mkdir -p /tmp/sam-box-$VM_ID
- sam-box run -u "$UDS_PATH" --data-dir "/tmp/sam-box-$VM_ID" > /var/log/sam-box-$VM_ID.log 2>&1 &
+ SAM_API_TOKEN="secret-token" sam-box run -u "$UDS_PATH" --data-dir "/tmp/sam-box-$VM_ID" --hub "https://bananas.sam-mesh.dev" --log-level debug > /var/log/sam-box-$VM_ID.log 2>&1 &
# Start Firecracker
firecracker --api-sock $API_SOCKET > /var/log/fc-$VM_ID.log 2>&1 &
diff --git a/site/content/docs/scale-experiment.md b/site/content/docs/scale-experiment.md
index 77dd6ac2..94bc1fef 100644
--- a/site/content/docs/scale-experiment.md
+++ b/site/content/docs/scale-experiment.md
@@ -83,3 +83,35 @@ To ensure cloud-init/startup finished properly on a newly created VM:
```bash
gcloud compute ssh sam-minions-1 --command="sudo tail -f /var/log/startup-script.log"
```
+
+## Phase 2: Chaos Agent AI Testing
+After provisioning the microVMs, each `chaos-agent` executes a script that routes local traffic to the host's `sam-box` control plane process over a Firecracker VSOCK socket.
+
+**Agent Capability Check:**
+The `chaos-agent` is implemented using Python, LangChain, and the MCP (Model Context Protocol) SDK. Upon boot, the agent:
+1. Discovers the MCP endpoint (which is mapped to the unauthenticated `sam-box` control plane port).
+2. Connects via Server-Sent Events (SSE) and lists available tools.
+3. Automatically iterates up to 10 times attempting to pass adversarial and chaotic inputs to the MCP tools to validate mesh resilience.
+4. Completes its LangChain execution loop and triggers an ACPI poweroff of the Firecracker MicroVM.
+
+**Current Testnet Scope:**
+During this experiment, because the sidecar (`sam-box`) was booted without an explicit node identity (no `--hub` or `SAM_API_TOKEN`), it ran in "unauthenticated enrollment mode", meaning the chaos-agent only tested the enrollment API surface.
+If a long-running load test is desired on the real Sovereign Agent Mesh network, the `max_iterations` constraint should be removed in the agent code and the host provisioned with an active `sam-mesh` token.
+
+## Running the Endurance Test
+
+To perform a continuous 10-minute load test against the real mesh network, SSH into the test machine and launch multiple concurrent MicroVMs. The agents will continuously attack the network for 500 iterations each.
+
+```bash
+gcloud compute ssh sam-test-2-1 --zone us-central1-c
+sudo /opt/microvm/launch-microvms.sh 10
+```
+
+You can monitor the live execution and adversarial outputs directly from the Firecracker console of the first VM:
+```bash
+sudo tail -f /var/log/fc-1.log
+```
+Or watch the sidecar gateway process:
+```bash
+sudo tail -f /var/log/sam-box-1.log
+```