Skip to main content

Module agents

Module agents 

Source
Expand description

Agent integration module for Grapsus proxy.

This module provides integration with external processing agents for WAF, auth, rate limiting, and custom logic. Agents communicate using the v2 binary protocol with bidirectional streaming, capabilities, health reporting, metrics export, and flow control.

§Architecture

  • AgentManager: Coordinates all agents, handles routing to appropriate agents
  • AgentV2: Agent with bidirectional streaming and connection pooling
  • AgentDecision: Combined result from processing through agents
  • AgentCallContext: Request context passed to agents

§Queue Isolation

Each agent has its own semaphore for queue isolation, preventing a slow agent from affecting other agents (noisy neighbor problem). Configure concurrency limits per-agent via max_concurrent_calls in the agent configuration.

§Example

use grapsus_proxy::agents::{AgentManager, AgentCallContext};

// Each agent manages its own concurrency limit (default: 100)
let manager = AgentManager::new(agent_configs).await?;
manager.initialize().await?;

let decision = manager.process_request_headers(&ctx, headers, &["waf", "auth"]).await?;
if !decision.is_allow() {
    // Handle block/redirect/challenge
}

Structs§

AgentCallContext
Agent call context.
AgentDecision
Agent decision combining all agent responses.
AgentManager
Agent manager handling all external agents.
AgentMetrics
Agent metrics collector.
AgentV2
Protocol v2 agent with connection pooling and bidirectional streaming.

Enums§

AgentAction
Agent action types.