Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ permissions:

jobs:
plugin:
name: plugin transpiles
name: openclaw plugin transpiles
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
Expand All @@ -38,20 +38,20 @@ jobs:
# what the build actually does. It catches syntax errors and bad imports;
# it does not type-check.
- name: esbuild
working-directory: extensions/substrate
working-directory: openclaw/extensions/substrate
run: |
npm install --omit=dev
npx --yes esbuild@0.24.2 \
index.ts acp-runtime.ts actor-router.ts actor-provisioner.ts \
ateapi-client.ts kubectl-ate-client.ts idle-suspender.ts \
--format=esm --platform=node --target=node20 --outdir=/tmp/dist
# build/gateway.Dockerfile lists the modules to transpile by hand. A new
# The gateway Dockerfile lists the modules to transpile by hand. A new
# module that nobody adds to that list is simply absent from the image,
# and esbuild will not complain, so check the list covers the directory.
- name: every module is in the Dockerfile's esbuild list
run: |
on_disk=$(cd extensions/substrate && ls *.ts | sort)
in_df=$(sed -n '/npx --yes esbuild/,/--outdir=dist/p' build/gateway.Dockerfile \
on_disk=$(cd openclaw/extensions/substrate && ls *.ts | sort)
in_df=$(sed -n '/npx --yes esbuild/,/--outdir=dist/p' openclaw/build/gateway.Dockerfile \
| grep -oE '[a-z0-9-]+\.ts' | sort -u)
missing=$(comm -23 <(echo "$on_disk") <(echo "$in_df"))
if [ -n "$missing" ]; then
Expand All @@ -61,14 +61,14 @@ jobs:
fi

dashboard:
name: dashboard parses
name: openclaw dashboard parses
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: "24"
- working-directory: demo/dashboard
- working-directory: openclaw/demo/dashboard
run: |
npm install --omit=dev
node --check dashboard.js
Expand Down Expand Up @@ -98,11 +98,17 @@ jobs:
# Every image reference has to be digest-pinned: Substrate refuses to
# snapshot a tag-pinned actor, and the gateway and actor drifting apart
# breaks the protocol they speak to each other.
#
# Allowed by tag: language base images, which a build resolves once and
# then pins in the image it produces; distroless and kubectl, which are
# utility images in jobs and sidecars rather than anything that is ever
# snapshotted.
- name: images are pinned by digest
run: |
if grep -rnE '^\s*(image|FROM)\s*:?\s+\S+:[a-zA-Z0-9._-]+\s*$' \
manifests/ build/*.Dockerfile demo/dashboard/k8s-manifest.yaml \
| grep -vE '@sha256:|golang:|node:|gcr\.io/cloud-builders|REPLACE_WITH'; then
files=$(git ls-files '*/manifests/*.yaml' '*/k8s/*.yaml' '*.Dockerfile' \
'*/Dockerfile' '*/Dockerfile.*' '*/k8s-manifest.yaml')
if grep -nE '^\s*(image|FROM)\s*:?\s+\S+:[a-zA-Z0-9._-]+\s*$' $files \
| grep -vE '@sha256:|golang:|node:|python:|gcr\.io/cloud-builders|REPLACE_WITH|distroless/|kubectl:'; then
echo "above image references are not pinned by digest"
exit 1
fi
Expand Down
22 changes: 14 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ requests are new to you.

## What belongs here, and what belongs upstream

This repo is an integration: it holds the OpenClaw plugin, the manifests, and
the demo. It deliberately carries no patches against
[`agent-substrate/substrate`](https://github.com/agent-substrate/substrate).
This repo holds reference integrations, one directory each, plus the pattern
they share. Nothing here is a patch against
[`agent-substrate/substrate`](https://github.com/agent-substrate/substrate), and
that is deliberate.

A new integration is a new top-level directory with its own README. Everything
it needs to build and deploy lives inside that directory, and the commands in
its README are run from there. What it shares with the others is the pattern,
not the code.

If you hit a gap in the Substrate control plane, file it there rather than
working around it here, and add a line to
[`substrate-patches/README.md`](substrate-patches/README.md) pointing at the
[`openclaw/substrate-patches/README.md`](openclaw/substrate-patches/README.md) pointing at the
issue or PR. Local patches bitrot, and the workaround usually outlives the bug.

Changes to OpenClaw itself go to
Expand All @@ -43,21 +49,21 @@ parses, the shell scripts pass `shellcheck` and `bash -n`, and that no file has
picked up an em dash. You can run the same checks locally:

```bash
npx esbuild@0.24.2 extensions/substrate/*.ts --format=esm --platform=node \
npx esbuild@0.24.2 openclaw/extensions/substrate/*.ts --format=esm --platform=node \
--target=node20 --outdir=/tmp/plugin-build
shellcheck demo/deploy-demo.sh
shellcheck openclaw/demo/deploy-demo.sh
```

Three conventions worth knowing, because they are easy to trip over:

- **Images are pinned by digest, never by tag.** Substrate snapshots require an
`@sha256`-pinned image, and the gateway and actor must sit on the *same*
OpenClaw base digest, since they speak OpenClaw's own protocol to each other.
`build/gateway.Dockerfile` and `build/actor.Dockerfile` get bumped together.
`openclaw/build/gateway.Dockerfile` and `openclaw/build/actor.Dockerfile` get bumped together.
- **The Substrate commit is pinned too.** `kubectl-ate` and `ateom` speak
internal protos to the control plane, so a floating clone drifts and fails
with opaque errors instead of version messages. The pin lives in
`build/gateway.Dockerfile` and `demo/README.md`, and both move together.
`openclaw/build/gateway.Dockerfile` and `openclaw/demo/README.md`, and both move together.
- **No em dashes**, in prose or in comments.

## Community guidelines
Expand Down
4 changes: 2 additions & 2 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ The current maintainers of this repository are listed below.
This repository is an integration under the `agent-substrate` organization. What
belongs here, how it is named, and how changes to Substrate itself are handled
are set by
[`docs/integration-repos.md`](https://github.com/agent-substrate/substrate/blob/main/docs/integration-repos.md)
[`docs/integration-repos.md`](https://github.com/agent-substrate/substrate/blob/main/docs/project/integration-repos.md)
in core. Maintainer roles and how people move between them follow the project
[Governance](https://github.com/agent-substrate/substrate/blob/main/GOVERNANCE.md).
There is no separate governance model for this repository.
Expand All @@ -19,7 +19,7 @@ There is no separate governance model for this repository.
- **It builds against Substrate as released.** No fork of core, no vendored
patch, no dependency on an unmerged change. When this integration needs
something core does not do, the core change lands first. The running list of
those is in [`substrate-patches/README.md`](substrate-patches/README.md).
those is in [`openclaw/substrate-patches/README.md`](openclaw/substrate-patches/README.md).
- **Gaps go upstream as issues or PRs** on
[`agent-substrate/substrate`](https://github.com/agent-substrate/substrate),
not as patches carried here.
Expand Down
198 changes: 69 additions & 129 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,139 +1,79 @@
# OpenClaw on Agent Substrate

Run OpenClaw personal-AI-assistant instances on GKE with [Agent Substrate](https://github.com/agent-substrate/substrate),
minimizing compute cost. OpenClaw agents are idle >95% of the time but must appear
online 24/7 for channels like WhatsApp. We resolve that by **splitting presence
from cognition**: an always-on gateway holds the channel connections, while the
expensive agent runs as a suspendable Substrate actor. The gateway suspends it
once the conversation goes idle, and the next message auto-resumes it on demand.

See [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) for the full design and tradeoffs (with diagrams),
and [Measured latency](docs/ARCHITECTURE.md#measured-latency) for what activation
actually costs and which bracket each number belongs to.

## Demo

[![OpenClaw on Agent Substrate: always-on agents, suspended when idle](docs/always-on-agents-demo-poster.jpg)](https://www.youtube.com/watch?v=D5a9tyPkaPY)

Two minutes, with narration. A WhatsApp message wakes an agent that is not
running, it answers from restored conversation state, checkpoints itself once the
conversation goes quiet, and then ten agents cycle through five machines while the
control plane is queried alongside.

Watch on [YouTube](https://www.youtube.com/watch?v=D5a9tyPkaPY), or download
[`docs/always-on-agents-demo.mp4`](docs/always-on-agents-demo.mp4) (3.7 MB, 1440p).

## How it integrates

### A drop-in plugin: zero edits to existing OpenClaw files
Everything lives in `extensions/substrate/`. Copy it into OpenClaw's `extensions/`
and enable it in `openclaw.json`. Config is declared in the plugin manifest
(`openclaw.plugin.json` → `configSchema`) and startup wiring runs through
OpenClaw's plugin service + hook API, so **no core OpenClaw file is modified**:
no changes to config types, Zod schema, `server.impl.ts`, channels, agents, or
skills.

```bash
cp -r extensions/substrate <openclaw>/extensions/substrate
# or bundle into the image: docker build --build-arg OPENCLAW_EXTENSIONS=substrate ...
```

Then set `plugins.entries.substrate` in config (see `extensions/substrate/README.md`).

The same logic can be wired straight into an OpenClaw build instead, as a
`src/substrate/` module plus about 30 lines of config and startup plumbing. That
was the original shape here and the plugin supersedes it, so it is not in this
repo.

## Repo layout

| Path | What |
|------|------|
| `extensions/substrate/` | The drop-in OpenClaw plugin (manifest, ACP backend, actor provisioner, idle suspender) |
| `manifests/` | Substrate + gateway K8s resources (WorkerPool, ActorTemplate, gateway, ingress) |
| `build/` | Image build: gateway/actor Dockerfiles, Cloud Build configs, actor image inputs (`build/actor/`) |
| `demo/` | WhatsApp demo config + deploy script + live dashboard |
| [`docs/`](docs/ARCHITECTURE.md) | Architecture doc + diagrams |

## Quick start (demo)

1. Install Substrate on a GKE cluster from a Substrate checkout with
`hack/install-ate.sh --deploy-ate-system`. Create the cluster with the
PodCertificate beta APIs enabled, and set up the snapshot bucket and its IAM
first; see [`demo/README.md`](demo/README.md) Step 1. (The packaged installer
at [`ai-on-gke/substrate-gke`](https://github.com/ai-on-gke/substrate-gke) does
all of that for you, but its pre-built image track is not usable yet.)
2. `export PROJECT_ID=… GCS_BUCKET=… GEMINI_API_KEY=…`
3. `cd demo && ./deploy-demo.sh` builds the images, pins them by digest, deploys
the WorkerPool, ActorTemplate, and gateway, then prints next steps (link
WhatsApp, send a message). See [`demo/README.md`](demo/README.md) for the full
walkthrough.

## For a harness company adopting this

- **Copy `extensions/substrate/`** into your OpenClaw tree (or bundle via
`OPENCLAW_EXTENSIONS`). No other OpenClaw code changes.
- **Config only, per deployment**: set `plugins.entries.substrate` on the gateway
(atespace, golden template, actor token, idle timeout) and ACP bindings in
`openclaw.json`. The actor image runs stock OpenClaw with no plugin.
- **On the Substrate side** (targets current OSS `agent-substrate/substrate`,
CRD group `ate.dev`): apply the `WorkerPool` + `ActorTemplate` manifests
(`ate.dev/v1alpha1`), point the gVisor `SandboxConfig` at a runsc build that
survives a heavy multi-process Node.js actor, and apply the control-plane
changes below. Actors use the **atespace** model
(`kubectl ate create atespace <a>; kubectl ate create actor <n> -a <a> --template-ref <name>`,
`--template` on Substrate main) and are reached through the atenet router, addressed
by Host `<actor>.<atespace>.actors.resources.substrate.ate.dev` on release-0.1 and by
the `ate-target-actor: <atespace>/<actor>` header on main. The gateway sends both.

### Substrate configuration this needs

It runs on stock Substrate. Earlier revisions of this file listed six
control-plane patches as prerequisites, and that list is obsolete. The cluster
behind [Measured latency](docs/ARCHITECTURE.md#measured-latency) runs `v0.1.0`
images for `atecontroller`, `atelet`, `ateom-gvisor` and `atenet` with no source
changes, the `gvisor-default` `SandboxConfig` exactly as the installer ships it,
and the default 20s golden warmup. No pinned runsc.

Two of the retired claims were wrong rather than merely stale, and
[`substrate-patches/README.md`](substrate-patches/README.md) records them so they
do not get repeated: a GKE-Sandbox `runsc` build is **not** required, and the
`ATE_*` environment knobs it described never existed upstream.

What is left is operator tuning. Both of these are `atenet-router` flags whose
defaults are low for an LLM harness:

| Flag | Default | Why it matters here |
|---|---|---|
| `--route-timeout` | 10s | Bounds one request from the ingress listener to the actor's response. The gateway relays an entire LLM completion over that request, so a turn longer than the default is cut off. |
| `--parked-request-budget` | 5s | Bounds how long a request waits for its actor to resume. Resume is 3.4s P50 here, so the default leaves little headroom on a cold node or a larger snapshot. |

Because the plugin integrates *below* the framework via OpenClaw's own ACP
protocol and plugin API, community-maintained channels/agents/skills, including
future ones, work unmodified.

## Contributing

See [`CONTRIBUTING.md`](CONTRIBUTING.md). Substrate control-plane gaps go
upstream as issues rather than as patches carried here; the running list is in
[`substrate-patches/README.md`](substrate-patches/README.md).

Who maintains this and under what rules is in
[`MAINTAINERS.md`](MAINTAINERS.md). This repository follows the project
# Always-on agents on Agent Substrate

Reference integrations that run a real agent on [Agent Substrate](https://github.com/agent-substrate/substrate),
one directory each, plus the pattern they share.

The problem each of them solves is the same. A personal-assistant agent is idle
well over 95% of the time, but it has to look online 24/7 for channels like
WhatsApp or Slack. Keeping a machine per agent while it does nothing is what
makes that shape expensive, and it is the cost that stops anyone running a large
fleet of them.

## The pattern

**Split presence from cognition.** An always-on gateway holds the channel
connections and stays cheap. The expensive part, the agent itself, runs as a
suspendable Substrate actor. The gateway suspends it once the conversation goes
idle, and the next inbound message resumes it on demand with its conversation
state intact.

![Split: always-on gateway plus a suspendable agent actor](docs/approach-split.png)

The alternative is to suspend the whole instance, channels included.

![Monolithic: the whole instance suspends and channels must be suspend-aware](docs/approach-monolithic.png)

That reaches true zero idle cost for channels where the platform holds the
connection and posts each message, which is a genuine edge. It falls over for
channels that hold a persistent socket: a suspended instance has a dead socket,
so nothing ever learns a message arrived and nothing triggers the resume. The
fallbacks all either keep the instance up, re-create the gateway under another
name, or poll. It also needs per-channel code changes, which is the maintenance
problem the split avoids.

Every integration here takes the split for socket-based channels. Where an agent
exposes an HTTP API of its own, the inbound request can drive the resume
directly and no presence layer is needed for that channel at all. The reasoning
in full, with the measurements behind it, is in each integration's own
architecture doc.

## What is in here

| Directory | What |
|---|---|
| [`openclaw/`](openclaw/README.md) | [OpenClaw](https://github.com/openclaw/openclaw) personal AI assistant on GKE: a drop-in plugin, the Kubernetes manifests, the image builds and a WhatsApp demo |
| [`hermes/`](hermes/README.md) | [Hermes Agent](https://github.com/NousResearch/hermes-agent) on GKE: a fleet of suspendable, self-improving agents behind one always-on gateway, with the manifests, actor image and busy-signal plugin |
| `docs/` | The two approach diagrams above, which are shared rather than belonging to any one integration |

Each integration directory is self-contained. Everything it needs to build and
deploy lives inside it, and the commands in its README are run from there.

## Adding one

Read [`CONTRIBUTING.md`](CONTRIBUTING.md) first. In short: a new integration is a
new top-level directory with its own README, and what it shares with the others
is the pattern rather than the code.

## Governance

Who maintains this and under what rules is in [`MAINTAINERS.md`](MAINTAINERS.md).
This repository follows the project
[Governance](https://github.com/agent-substrate/substrate/blob/main/GOVERNANCE.md)
and the conventions in
[`docs/integration-repos.md`](https://github.com/agent-substrate/substrate/blob/main/docs/integration-repos.md),
[`docs/integration-repos.md`](https://github.com/agent-substrate/substrate/blob/main/docs/project/integration-repos.md),
rather than defining its own.

Nothing here is a patch against Substrate. When an integration needs something
the control plane does not do, the core change lands upstream first.

## License

Apache License 2.0. See [`LICENSE`](LICENSE).

## Trademarks

[OpenClaw](https://github.com/openclaw/openclaw) is an independent open-source
project (MIT-licensed). This repository provides an integration that runs
OpenClaw on Agent Substrate; it is **not affiliated with, sponsored by, or
endorsed by** the OpenClaw project. "OpenClaw" and any related names or logos are
the property of their respective owners and are used here only descriptively to
identify the software being integrated.
The agents integrated here are independent open-source projects and are not
affiliated with, sponsored by, or endorsed by this repository or its maintainers.
Their names and logos are the property of their respective owners and are used
only descriptively, to identify the software being integrated. Per-project
trademark notices are in each integration's README.
Binary file modified docs/approach-split.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading