Skip to main content

🐇 Hoppers

A small, fast Python library for running many LLM agents at once.

Sessions hop through queues, agents answer, tools act, memory reads and writes at the edges.

Python 3.12+ uv No agent framework Providers

Hoppers is for places where many actors have to decide quickly: games, where every NPC is a session, and research, where many independent items are in flight at once. It owns the runtime loop and the prompt layout, so it stays small and adds very little time on top of the model call.

Highlights

  • Sessions as the unit of work. A session carries its own history and moves through queues by value, with exclusive ownership. Thousands can be in flight on one event loop.
  • Fast by default. Pooled HTTP connections, streaming, prefix-cache-friendly prompts, and per-turn timing (queue wait, time to first output, tool latency, tokens) built in.
  • Batching. The bulk profile sends sessions already waiting on the same agent in one call.
  • Any model. OpenAI, Anthropic, Gemini, and any OpenAI-compatible server (Ollama, vLLM, SGLang).
  • Pluggable queues. An in-process asyncio queue by default, or a ZeroMQ broker with the same interface when workers live in other processes.
  • Roles and handoffs. A session can change role mid-conversation (guard to merchant).
  • Tools in one decorator. @hop.tool turns a function into a tool, and hoppers.toolchain ships a set of ready-made ones.
  • Long-term memory. Memory over a swappable MemoryStore, with optional embeddings.
  • Response cache. CachedChatModel skips repeated prompts for deterministic research runs.
  • Live dashboard. hoppers.visualization.serve shows the queue graph, sessions, and latency.
  • Light. Four runtime dependencies: pyzmq, pyyaml, httpx, sniffio.

Install

Hoppers needs Python 3.12 or newer.

git clone https://github.com/nimaiji/hoppers.git
cd hoppers
uv sync

Or add it to another project straight from GitHub:

uv add git+https://github.com/nimaiji/hoppers.git

Optional extras for the built-in toolchain:

uv sync --extra toolchain     # everything below
uv sync --extra web           # CSS selectors in fetch_url
uv sync --extra pdf           # markdown_to_pdf, read_pdf

Quick start

import asyncio
import hoppers as hop

llm = hop.connect_llm("openai", api_key=KEY, model="gpt-4o")

@hop.tool
def speak(text: str) -> str:
    """Say something out loud."""
    return f"said: {text}"

@hop.tool
def move(place: str) -> str:
    """Move to a place: gate, market or tavern."""
    return f"moved to {place}"

guard = hop.Agent("You are a town guard.", llm=llm)
merchant = hop.Agent("You are a market merchant.", llm=llm)

async def main():
    async with hop.App(
        agents={"guard": guard, "merchant": merchant},
        tools=[move, speak],
    ) as app:
        npc = app.session("npc-17", role="guard", instruction="Keeps watch at the north gate")

        result = await app.submit(npc, "A stranger approaches")

        # or watch it happen:
        async for event in app.stream(npc, "A stranger approaches"):
            print(event)

asyncio.run(main())

Providers

hop.connect_llm("openai", api_key=KEY, model="gpt-4o")
hop.connect_llm("anthropic", api_key=KEY, model="...")
hop.connect_llm("google", api_key=KEY, model="...")
hop.connect_llm("local", base_url="http://localhost:11434/v1", model="llama3.1:8b")  # Ollama etc.
hop.connect_llm("vllm", model="...")      # http://localhost:8000/v1
hop.connect_llm("sglang", model="...")    # http://localhost:30000/v1

Tuning for your workload

# Games and chat: lowest latency per turn (the default)
hop.App(agents=..., profile="interactive")   # one call per session, up to 64 in flight

# Research and bulk jobs: highest throughput
hop.App(agents=..., profile="bulk")          # batches of up to 32, up to 256 in flight

# Several machines or processes
hop.App(agents=..., queue="zmq")             # ZeroMQ broker, same put/get behaviour

Explicit arguments (batch_size, batch_wait, concurrency, tool_concurrency) always win over the profile. ready= lets a session wait on its dependencies without holding a slot, so one NPC can run ahead as soon as its neighbours catch up instead of waiting for a global tick.

Built-in tools

hoppers.toolchain gives agents ready-made tools. Each group is a small class and .tools() returns ordinary hop.Tool objects, so they work anywhere a tool does.

from hoppers import toolchain

tools = toolchain.default_tools("./workspace")                 # safe set, no shell
tools += toolchain.ShellTools("./workspace", allow_execution=True,
                              allowed_commands=["python", "git"]).tools()
tools += toolchain.KeyValueStore().tools()                     # notes shared between agents

app = hop.App(agents={"researcher": agent}, tools=tools)
Group Tools
FileTools(root) read_file write_file edit_file list_dir find_files grep
ShellTools(root) run_command run_python (opt-in)
WebTools() fetch_url (text, links, CSS selector)
HttpTools(allowed_hosts=...) http_request
SearchTools(backend) web_search (DuckDuckGo, Brave, Tavily)
PdfTools(root) markdown_to_pdf read_pdf
DataTools(root) read_csv csv_stats json_query
CalcTools() calculate roll_dice
ClockTools(now=...) current_time convert_time add_time
KeyValueStore() kv_set kv_get kv_list kv_delete

Safety is the default: paths cannot escape their root, shell and Python execution are off until you enable them, network tools refuse private and loopback addresses, and the calculator parses arithmetic with ast instead of eval. These are guard rails, not a sandbox. Run untrusted models in a container. Details are in the toolchain guide.

Performance

Hoppers ships with evals/, a benchmark harness that runs the same workload through Hoppers and other agent frameworks against one deterministic OpenAI-compatible server, so the framework is the only variable. Each trial is a fresh subprocess, contestants run in randomised order, and differences are judged with paired bootstrap confidence intervals. See evals/README.md for the method.

Run market-standard-2: 8 repetitions per scenario, 0 crashed trials, every answer exact-match correct. Throughput in turns per second, higher is better (median):

Scenario Hoppers AutoGen OpenAI Agents SDK LangGraph
Pure framework overhead (zero-latency server) 582 381 296 288
200 NPCs deciding at once 481 367 310 275
Multi-turn with history recall 505 231 207 191
Long shared context 434 333 289 261
Three parallel tools per turn 427 298 240 218
  • Among the frameworks, Hoppers has the highest throughput and lowest latency in every scenario above, using about half the CPU per turn and 2x to 3x less memory than LangGraph.
  • Against a hand-written asyncio loop (raw), Hoppers is slower: that loop is the floor and Hoppers adds roughly 1.5 to 2 ms of CPU per turn for sessions, queues, batching and measurement. The evaluation includes it so the cost of the framework layer stays visible.
  • In a 5,000-session run (5 repetitions, too few for a significance verdict), Hoppers finished about 3.4x faster than AutoGen with under a third of its memory.
  • Numbers come from one machine with a mock model server. Compare the ratios, not the absolute values, and rerun evals/ on your hardware.

Live dashboard

from hoppers.visualization import serve

async with hop.App(...) as app:
    async with serve(app, port=8765) as url:
        print(f"Dashboard: {url}")
        ...  # submit sessions here

It shows the queue graph, where each session is, worker occupancy, and rolling latency. It runs on localhost and needs no extra dependencies.

Design

  • Agents hold instructions, a model connection, and a KV cache handle. They do not hold queues, tools, or memory.
  • Sessions move by value through queues. Ownership is exclusive (acquire / release).
  • Queues are in-process asyncio queues with aging priority by default. queue="zmq" uses a ZeroMQ broker with the same put / get behaviour, including across processes.
  • Batching. batch_size above 1 sends sessions already waiting on the same agent in one LLM call. Replies return in order and each session continues on its own. A single waiting session still streams.
  • No framework underneath. Model connections (ChatModel with OpenAI, Anthropic and Gemini adapters over plain HTTP), messages, tools, and memory are Hoppers' own classes. Hoppers owns the prompt layout and the runtime loop.
  • Measured. Every turn records queue wait, time to first output, time to decision, tool latency, and tokens when the provider reports them (TurnRecord).

Repository layout

Path Contents
src/hoppers/ Package root: llm, tools, memory, cache
src/hoppers/core/ Agent, session, queue (memory and ZeroMQ), prompt policies, app, measurement
src/hoppers/providers/ OpenAI-compatible, Anthropic and Gemini adapters
src/hoppers/toolchain/ Built-in tools (guide)
src/hoppers/visualization/ Live dashboard
evals/ Benchmark harness against other frameworks (guide)
tests/ Pytest suite

Development

uv sync
uv run pytest

Tests use scripted fake models, so they need no network and no API keys.

Metadata

Release files for hoppers 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hoppers 0.1.0
File Size Uploaded Provenance Actions
hoppers-0.1.0.tar.gz 91.9 kB Without provenance Details for hoppers-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hoppers 0.1.0
File Interpreter ABI Platform Actions
hoppers-0.1.0-py3-none-any.whl Python 3 none any Details for hoppers-0.1.0-py3-none-any.whl

Total release size: 202.3 kB

Release files / hoppers-0.1.0.tar.gz

Download URL hoppers-0.1.0.tar.gz
Size 91.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e2788764bb0fb593b47f2dcf12e021652e153cc140fa6d1bcb0d241439e31122
BLAKE2b-256 checksum
How to use checksums
41d161647213bf48c52392b9bdf8ba13672e199ea9613aa413f3c739980e8356
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / hoppers-0.1.0-py3-none-any.whl

Download URL hoppers-0.1.0-py3-none-any.whl
Size 110.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f71c2a036c5bf80c1559031eddaea503c489ce131c3c450e36e86c9061eeab7a
BLAKE2b-256 checksum
How to use checksums
ac54d34ded0d79b969c61ac71b2a3b9cb4820a56d5cdeecfb4781cdb19942dad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for hoppers 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page