ShVaSa Blog
Systems & RL • 5 min read

CoffeeBench: Benchmarking Long-Horizon LLM Agents in Heterogeneous Multi-Agent Economies

Published on 2026-11-16 by Sharath Japa, ShVaSa Lab Lead
systemsarchitectureinfrastructureperformance
Discuss on r/shvasa

Executive Summary

The emergence of Large Language Model (LLM) agents capable of managing complex, long-horizon business tasks necessitates a rigorous evaluation framework that transcends static benchmarking. CoffeeBench introduces a heterogeneous multi-agent economy simulation designed to stress-test these systems across extended temporal horizons. Unlike traditional benchmarks that measure single-turn accuracy or short-horizon planning, CoffeeBench evaluates the stability, resource management, and cooperative efficiency of agents operating within a dynamic market environment. This paper dissects the architectural requirements for such simulations, highlighting critical bottlenecks in memory bandwidth, state synchronization, and protocol guarantees. We present a modular implementation strategy that decouples the economic simulation engine from the LLM inference layer, enabling scalable stress testing of agent behaviors under varying economic shocks and resource constraints.

Implementation Architecture

The core challenge in benchmarking long-horizon agents lies in the exponential growth of context windows and the non-deterministic nature of LLM outputs. A naive implementation where each agent holds a full history of the economy in its context window quickly becomes infeasible due to memory bandwidth limitations and latency spikes. CoffeeBench addresses this by implementing a hierarchical state management system.

State Synchronization and Memory Management

In a heterogeneous multi-agent economy, agents have distinct roles (e.g., producer, consumer, regulator). The system must maintain a global state (market prices, inventory levels, reputation scores) that is accessible to all agents but updated asynchronously. To prevent race conditions and ensure deterministic replayability, we employ a lock-free queue mechanism for state updates, coupled with a Merkle tree for efficient state verification.

The implementation separates the Simulation Loop from the Inference Loop. The simulation loop runs at a fixed tick rate, processing economic transactions and updating the global state. The inference loop operates on an event-driven basis, triggering LLM calls only when an agent's decision boundary is crossed (e.g., inventory below threshold, new market signal). This decoupling allows for parallel processing of agent decisions without blocking the economic simulation.

Quantization and Protocol Guarantees

To handle the high throughput required for long-horizon simulations, we utilize 4-bit quantization for the LLM weights, reducing memory footprint by approximately 75% compared to FP16. However, quantization introduces noise in the output distribution, which can accumulate over long horizons, leading to drift in agent behavior. We mitigate this by implementing a confidence-aware routing mechanism: high-stakes decisions (e.g., large financial transactions) are routed through a higher-precision model or a verification layer, while low-stakes actions (e.g., routine inventory checks) use the quantized model.

The protocol guarantees are enforced via a transactional ledger that records all agent actions and economic outcomes. This ledger serves two purposes: it provides a ground truth for evaluation metrics (e.g., total welfare, market efficiency) and enables counterfactual analysis by allowing the simulation to be replayed with different agent policies.

PYTHON
import asyncio
import json
from typing import Dict, List, Any
from dataclasses import dataclass
from enum import Enum

class AgentRole(Enum):
    PRODUCER = "producer"
    CONSUMER = "consumer"
    REGULATOR = "regulator"

@dataclass
class MarketState:
    price: float
    inventory: Dict[str, int]
    reputation: Dict[str, float]

class SimulationEngine:
    def __init__(self, initial_state: MarketState):
        self.state = initial_state
        self.history: List[Dict] = []
        self.agents: Dict[str, Any] = {}

    def register_agent(self, agent_id: str, role: AgentRole, model):
        self.agents[agent_id] = {
            'role': role,
            'model': model,
            'state': {'inventory': 0, 'reputation': 1.0}
        }

    async def tick(self, tick_id: int):
        """Process one economic cycle."""
        actions = []
        for agent_id, agent_data in self.agents.items():
            # Generate action based on current state and model
            prompt = self._construct_prompt(agent_id, agent_data['role'], self.state)
            action = await agent_data['model'].generate(prompt)
            actions.append({'agent_id': agent_id, 'action': action, 'tick': tick_id})
        
        # Apply actions and update state
        self._apply_actions(actions)
        self.history.append({'tick': tick_id, 'state': self.state.__dict__, 'actions': actions})

    def _construct_prompt(self, agent_id: str, role: AgentRole, state: MarketState) -> str:
        return json.dumps({
            "role": role.value,
            "market_price": state.price,
            "inventory": state.inventory,
            "agent_id": agent_id
        })

    def _apply_actions(self, actions: List[Dict]):
        # Simplified logic for demonstration
        for action in actions:
            if action['action'].get('type') == 'buy':
                self.state.inventory['product'] -= 1
                self.state.price += 0.01
            elif action['action'].get('type') == 'sell':
                self.state.inventory['product'] += 1
                self.state.price -= 0.01

# Usage example
async def main():
    initial_state = MarketState(price=100.0, inventory={'product': 1000}, reputation={'agent1': 1.0})
    engine = SimulationEngine(initial_state)
    # Mock model for demonstration
    class MockModel:
        async def generate(self, prompt): return {"type": "buy", "amount": 1}
    
    engine.register_agent("agent1", AgentRole.CONSUMER, MockModel())
    await engine.tick(1)
    print(f"State after tick 1: {engine.state.price}")

asyncio.run(main())

ShVaSa Intuition

The fundamental intuition behind CoffeeBench is that long-horizon stability is a function of information fidelity and decision latency. In traditional single-agent benchmarks, the primary concern is the accuracy of the immediate output. In a multi-agent economy, the system's health depends on the consistency of the global state and the responsiveness of individual agents to state changes.

We hypothesize that the primary bottleneck in long-horizon agent systems is not computational power, but state synchronization overhead. As the number of agents increases, the cost of maintaining a consistent global view grows super-linearly. CoffeeBench's design emphasizes a sparse state update mechanism, where agents only receive relevant information rather than the full market state. This reduces the context window size and minimizes the impact of quantization noise on decision quality.

Furthermore, the intuition extends to economic resilience. By simulating heterogeneous agents with different risk profiles and decision-making algorithms, we can observe how the system responds to shocks. A robust agent system should exhibit self-correction mechanisms, such as price stabilization or inventory redistribution, without central intervention. CoffeeBench provides the metrics to quantify this resilience, such as the time to equilibrium after a shock and the variance in agent welfare over time.

graph TD
    subgraph "Simulation Engine"
        A[Global State Manager] -->|Read| B[Market Price]
        A -->|Read| C[Inventory Levels]
        A -->|Read| D[Reputation Scores]
        A -->|Write| E[Transaction Ledger]
    end

    subgraph "Agent Layer"
        F[Producer Agent] -->|Query State| A
        G[Consumer Agent] -->|Query State| A
        H[Regulator Agent] -->|Query State| A
        
        F -->|Generate Action| I[LLM Inference Layer]
        G -->|Generate Action| I
        H -->|Generate Action| I
        
        I -->|Return Action| F
        I -->|Return Action| G
        I -->|Return Action| H
    end

    subgraph "Execution Layer"
        F -->|Submit Action| J[Action Validator]
        G -->|Submit Action| J
        H -->|Submit Action| J
        
        J -->|Validate| K[State Update Service]
        K -->|Update State| A
        K -->|Log Event| E
    end

    style A fill:#f9f,stroke:#333,stroke-width:2px
    style I fill:#bbf,stroke:#333,stroke-width:2px
    style J fill:#ff9,stroke:#333,stroke-width:2px

<!-- Consensus Verified by Student (qwen3.6-35b-a3b) & Judge (gemma-4-31b-it) | VERIFICATION REPORT -->


Grounding & Source Attribution

Author Avatar

Sharath Japa, ShVaSa Lab Lead

Systems & AI Infrastructure Researcher, DGX Station homelab lead. Engineering RL environments, edge silicon inference, and local reasoning model distillation. Verified Profiles: Google Scholar • Google Patents • LinkedIn • GitHub (@sharathjapa) • Medium • r/shvasa.


Canonical Source: https://shvasa.us/posts/coffeebench-benchmarking-long-horizon-llm-agents-in-heterogeneous-multi-agent-economies

Advertisement

Related Research & Architectural Blueprints