2 min read

Production Integration#

This guide walkthroughs a flagship implementation of the VEX Protocol. You will learn how to orchestrate a multi-layered verification loop that includes intelligent routing, adversarial debate, persistent memory, and blockchain anchoring.

Initialize the Intelligence Layer

We start by configuring vex-router. This layer intelligently routes queries based on complexity and cost. It also automatically detects adversarial intent in system prompts to upgrade verification quality.

Rust
use vex_router::{Router, RoutingStrategy, ModelConfig};

let router = Router::builder()
    .strategy(RoutingStrategy::Balanced)
    .add_model(ModelConfig::openai("gpt-4o"))
    .add_model(ModelConfig::deepseek("deepseek-chat"))
    .build();

Configure the Agent Genome

Define your agent's behavioral traits. In this example, we configure a "Scientific Researcher" DNA with high skepticism and precision.

Rust
use vex_core::{Agent, AgentConfig, Genome};

let mut agent = Agent::new(AgentConfig {
    name: "Researcher".to_string(),
    role: "You are a rigorous scientific analyst.".to_string(),
    genome: Genome {
        skepticism: 0.9,     // High critical thinking
        precision: 0.8,      // Fact-heavy output
        creativity: 0.3,     // Low hallucination risk
        ..Default::default()
    },
    ..Default::default()
});

Orchestrate with AgentExecutor

Use vex-runtime to wrap the agent and LLM into a verified execution loop. This automatically triggers a Red/Blue adversarial debate if VEX_ADVERSARIAL_ENABLED is set.

Rust
use vex_runtime::{AgentExecutor, ExecutorConfig};

let executor = AgentExecutor::new(
    router, 
    ExecutorConfig {
        max_debate_rounds: 3,
        enable_adversarial: true,
        ..Default::default()
    }
);

Execute & Persist

Run the agent. The output is automatically hashed into a Merkle tree and stored in vex-persist along with its vector embeddings for future context retrieval.

Rust
let result = executor.execute(&mut agent, "Analyze this dataset...").await?;

// Store in VectorStore for 0.1.5 persistence
let vector_store = SqliteVectorStore::new(dim, pool).await?;
vector_store.add(result.id, agent.tenant_id, result.embedding, result.metadata).await?;

Anchor to Blockchain

Finalize the trust chain by anchoring the Merkle root to a public ledger. This provides mathematical proof to third parties that the execution trace was generated at a specific time and hasn't been tampered with.

Rust
use vex_anchor::{EthereumAnchor, AnchorMetadata};

let anchor = EthereumAnchor::new(rpc_url).await?;
let receipt = anchor.anchor(&result.context.hash, AnchorMetadata::new(tenant, block)).await?;

println!("Proof anchored! TX: {}", receipt.tx_hash);

Architecture Flow#

The following diagram illustrates the complete integration data flow:

Generating technical diagram...
Production Readiness

For high-throughput systems, ensure you configure vex-queue to handle anchoring asynchronously to avoid blocking the main agent execution loop.

Was this page helpful?
Edit this page on GitHub