1-SEC contributors · Reviewed · Module: ai_containment

Cascading Agent Failures and Retry Storm Monitoring

Failure tracking records errors within a five-minute window and counts retry-like error types.

What 1-SEC checks

Failure tracking records errors within a five-minute window and counts retry-like error types. The current retry-storm condition is more than twenty retry observations. Cascade analysis considers distinct downstream targets and repeated errors, using the reported agent relationships.

Read the implementation: handleCascadeFailure

Required telemetry and context

Relevant input events: agent_error, agent_timeout, agent_retry. Use a trusted producer at the real application boundary.

  • agent_id
  • error_type
  • target_agent

Field names above describe relevant context, not a complete API request. Consult the current event contract for envelope and detail requirements. Preserve booleans, numbers, and strings as the receiving handler expects them. Agent-provided text cannot independently verify identity or authorization.

Deployment, prevention, and response

Correlate error timing with infrastructure health and actual downstream requests. Apply backoff, timeouts, and circuit breakers in the orchestrator/service layer. Preserve the origin and target identifiers and avoid simply retrying a failed destructive operation.

Record the source event, affected agent/host, actual target, policy decision, and response result. Review enforcement configuration separately from detection. A recommendation, selected action, dry-run record, and completed action are different outcomes.

Reproduce the source fixtures

From a checkout of the linked 1-SEC source revision, run the selected fixtures with the repository's Go toolchain. These commands run tests; they do not execute a real attack against your systems.

go test ./internal/modules/aicontainment -run '^(TestCascadeFailure_RetryStorm|TestCascadeFailure_NoCascade)$' -count=1

The referenced source fixtures ran in the selected local package suites. Helper tests and synthetic events establish only the assertions shown, not production prevention or framework compatibility.

TestCascadeFailure_RetryStorm

Full fixture and assertions — run in its original package with its helpers.

func TestCascadeFailure_RetryStorm(t *testing.T) {
	cm := NewCascadeFailureMonitor()
	var result CascadeResult
	for i := 0; i < 25; i++ {
		result = cm.Record("agent-1", "retry_timeout", "")
	}
	if !result.RetryStorm {
		t.Error("expected RetryStorm after 20+ retries")
	}
}
TestCascadeFailure_NoCascade

Full fixture and assertions — run in its original package with its helpers.

func TestCascadeFailure_NoCascade(t *testing.T) {
	cm := NewCascadeFailureMonitor()
	result := cm.Record("agent-1", "minor_error", "")
	if result.CascadeDetected {
		t.Error("single error should not trigger cascade")
	}
	if result.RetryStorm {
		t.Error("single error should not trigger retry storm")
	}
}

// ─── HandleEvent Integration ──────────────────────────────────────────────────

Tuning, evaluation, and coverage limits

An event named agent_retry still needs an appropriate error_type for the retry counter. Shared outages can produce similar patterns without compromise. This monitor does not implement retry backoff, circuit breakers, service failover, or guaranteed propagation tracing.

Evaluate this behavior with representative authorized activity and a controlled known-positive case. Investigate the exact rule, inputs, and state before suppressing an alert. Do not assume a hard-coded heuristic is a configurable setting. Measure your own deployment; the source fixtures do not establish a benchmark, detection rate, compliance certification, or incident-prevention claim.

Related implemented controls

Implementation reviewed at source revision 2af8ea9dab2057a1ffc3cce9bf44220271fab18e. Recheck the actual release and integration before deployment. Sources and corrections policy.