ContextPilot plugin

A context engine for OpenClaw and Hermes Agent that reorders blocks and removes repeats so the prefix cache hits more often

  • 146 ★ on the repository
  • Last commit
  • Apache-2.0
Plugin

Extended access

Why this level

  • In HTTP proxy mode the service sits between the agent and the model API and sees every agent request, and `install_hook` writes a `.pth` file into site-packages and loads the integration on every Python start.
  • Reordering and replacing repeats change the request text, so results should be compared on tasks with a rigid prompt structure.
All reasons and checks

efficientcontext/contextpilot

Install

Manual install

openclaw plugins install @contextpilot-ai/contextpilot

Then assign the `contextEngine` slot in `~/.openclaw/openclaw.json` and restart OpenClaw.

Access and checks

How we review

Extended accessThe tool runs code or makes network calls and only reads external data.

  • In HTTP proxy mode the service sits between the agent and the model API and sees every agent request, and `install_hook` writes a `.pth` file into site-packages and loads the integration on every Python start.
  • Reordering and replacing repeats change the request text, so results should be compared on tasks with a rigid prompt structure.

This is third-party code. Review the repository files before installing.

What it does

ContextPilot is a layer between context assembly and inference. Long requests (RAG, memory chat, tool-using agents) assemble many blocks that repeat from request to request but arrive in a different order; the token prefix changes, the cache misses and attention keys and values are recomputed. ContextPilot keeps an index of cached content and, per request, reorders blocks so the shared part comes first (Reorder) and replaces repeats with references (Deduplicate). Agents get ready-made integrations. For OpenClaw there is a native plugin, `openclaw plugins install @contextpilot-ai/contextpilot`, after which the `contextEngine` slot in `~/.openclaw/openclaw.json` is assigned to ContextPilot; an HTTP proxy mode covers self-hosted models and custom backends. For Hermes Agent, run `hermes plugins install EfficientContext/ContextPilot` and pick Context Engine, ContextPilot in the plugin list. For vLLM and SGLang, `pip install contextpilot` wires the hooks, and Mac works through llama.cpp. In the authors' measurement on 60 document-analysis tasks in OpenClaw (Qwen3-4B on SGLang, RTX 5090), request tokens dropped by 26.5% on average and mean response time by 20.4%, and all 245 answers stayed correct.

Who it is for. People running OpenClaw or Hermes Agent on their own models through vLLM, SGLang or llama.cpp who are hitting the cost of long context.

Good fit when

  • An OpenClaw agent keeps re-reading the same files and model requests grow with every step.
  • The model runs on your own GPU under SGLang or vLLM and prefill speed limits the work.
  • A memory chat (Mem0, PageIndex) mixes many overlapping blocks into the request.
  • A cloud API should be used more economically: cache sync is documented for OpenAI, Anthropic and MiniMax.

Not a fit when

  • The context is short and does not repeat across requests: the prefix cache gain will be small.
  • Block order in the request is fixed by task rules: reordering would change it.
  • The agent is a different one and you do not want a proxy in your code: native plugins exist only for OpenClaw and Hermes Agent.

Example request

Connect ContextPilot as the context engine in OpenClaw, run the same set of 60 tasks with and without it and compare tokens per request.

Limitations

Python 3.10 or newer is required. The gain depends on the request itself: it shows where many blocks are shared, and the README figures apply to specific models and GPUs. The GPU index needs `contextpilot[gpu]` on CUDA 12.x. A source install requires a separate `python -m contextpilot.install_hook` for vLLM and SGLang, and on a Mac with llama.cpp `xcode-select --install` is needed to build the native hook. After changing the slot in `openclaw.json`, restart the agent.

How to disable. In OpenClaw set the `contextEngine` slot back to its default and disable the `contextpilot` entry; in Hermes Agent choose a different Context Engine in `hermes plugins`; the vLLM and SGLang hook is removed with `python -m contextpilot.install_hook --remove`.

FAQ

How do I install ContextPilot in OpenClaw?

Run `openclaw plugins install @contextpilot-ai/contextpilot`. Then set `"contextEngine": "contextpilot"` under `plugins.slots` in `~/.openclaw/openclaw.json` and enable the entry under `plugins.entries`. After a restart the plugin runs in-process and no proxy is needed.

How do I connect ContextPilot to Hermes Agent?

Run `hermes plugins install EfficientContext/ContextPilot`, then pick Context Engine and ContextPilot in `hermes plugins`. No Hermes source changes are needed.

What does ContextPilot do to a request?

It finds blocks already in the model cache, puts them into a common prefix and replaces repeats with references. The optimized request goes out over the OpenAI-compatible API, and `POST /evict` tells the index about evicted blocks.

Which inference engines does it work with?

vLLM, SGLang and llama.cpp (including Macs with Apple Silicon), plus the OpenAI, Anthropic and MiniMax cloud APIs through cache sync.

Does reordering lower answer quality?

In the authors' measurements accuracy stayed the same: 245 of 245 in the OpenClaw test and close judge scores on LoCoMo. Verify that result on your own tasks.

Discussion

No questions or reviews yet.

Plugins

The context-optimizer plugin shows Claude session cost, trims context and hands file reads and tests to cheap Haiku agents.

PluginExtended access130Repository stars

A local proxy and plugin for Claude Code and Codex that trims tool output, keeps the prompt cache warm and shows the savings

PluginBroad access74Repository stars

A local context layer for coding agents: it understands the task, routes and compresses context and tracks the cost

CLIExtended access3.9KRepository stars

A Hermes plugin and OpenClaw skill: memory over Obsidian and markdown notes through a concept graph and local semantic search

PluginExtended access66Repository stars

A plugin marketplace for agents: reflexion, code and PR review, git, TDD, DDD, specs and subagent-driven development

PluginExtended access1.8KRepository stars

Comparison with similar tools

Cards that share the main search query, and how they differ.

ToolOfficialAuthenticationRepository starsMain difference
ContextPilot (this card)no146
Context Modenonot required34,013an MCP server that saves the agent's context window on the tools side; ContextPilot works on the inference side and reorders blocks for prefix caching
Context Engineering Kitno1,821a plugin set with context-building practices; ContextPilot reorders and deduplicates ready context automatically

README in short

The README opens with headline numbers, news and a statement of the problem, then shows measurement tables for OpenClaw, Mem0 and llama.cpp. Installation is split by environment: OpenClaw, Hermes Agent, vLLM and SGLang, Mac. Links lead to the MLSys 2026 paper and the docs.

README badge

Report a problem