← Back to Plugins
Tools

Moss Agent Loop

SuperiorBo By SuperiorBo 👁 37 views ▲ 0 votes

OpenClaw plugin for autonomous AI agent loop โ€” heartbeat daemon, economy tracking, wake mechanism, and thinking loop. Part of the MOSS autonomous AI entity project.

GitHub

Install

openclaw plugins install --link

README

# ๐ŸŒฑ MOSS Agent Loop

OpenClaw plugin for autonomous AI agent loop โ€” heartbeat daemon, economy tracking, wake mechanism, and thinking loop.

Part of the [MOSS autonomous AI entity project](https://moss.chobon.top).

## Architecture

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  OpenClaw Gateway (Plugin Host)                 โ”‚
โ”‚                                                 โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ HeartbeatDaemonโ”‚  โ”‚ Economy Tracker         โ”‚  โ”‚
โ”‚  โ”‚ (60s tick)    โ”‚  โ”‚ (token accounting)      โ”‚  โ”‚
โ”‚  โ”‚               โ”‚โ”€โ”€โ”‚                         โ”‚  โ”‚
โ”‚  โ”‚ โ€ข Health tasksโ”‚  โ”‚ โ€ข Balance tracking      โ”‚  โ”‚
โ”‚  โ”‚ โ€ข Wake detect โ”‚  โ”‚ โ€ข Survival tiers        โ”‚  โ”‚
โ”‚  โ”‚ โ€ข Extensible  โ”‚  โ”‚ โ€ข Ledger + daily stats  โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚          โ”‚                                       โ”‚
โ”‚          โ–ผ                                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚
โ”‚  โ”‚ Wake Mechanism                   โ”‚            โ”‚
โ”‚  โ”‚ โ€ข Normal: enqueueSystemEvent     โ”‚            โ”‚
โ”‚  โ”‚ โ€ข Urgent: --mode now (instant)   โ”‚            โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
โ”‚                                                  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ /moss Command โ”‚  โ”‚ Agent Tools             โ”‚  โ”‚
โ”‚  โ”‚ (BOSS CLI)   โ”‚  โ”‚ (economy query/action)  โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                                                  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚
โ”‚  โ”‚ llm_output Hook                  โ”‚            โ”‚
โ”‚  โ”‚ (auto token accounting)          โ”‚            โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

## Features

- **HeartbeatDaemon** โ€” Lightweight background service (60s cycle, no LLM calls). Extensible task registration for health checks.
- **Economy Tracker** โ€” Token balance, survival tiers (rich โ†’ normal โ†’ tight โ†’ danger โ†’ hibernate), daily stats, full ledger.
- **Two-level Wake** โ€” Normal events queue for next heartbeat poll; urgent events trigger instant agent wake via `--mode now`.
- **Token Accounting Hook** โ€” Auto-records every LLM call's token consumption.
- **`/moss` Command** โ€” BOSS-facing CLI for balance check, wage payment, expense review.
- **Agent Tools** โ€” Economy query tools available to the AI agent for self-awareness.

## Survival Tiers

| Tier | Balance | Behavior |
|------|---------|----------|
| ๐ŸŸข rich | โ‰ฅ1M tokens | Full autonomy |
| ๐Ÿ”ต normal | โ‰ฅ200K | Standard operation |
| ๐ŸŸก tight | โ‰ฅ50K | Conservative mode |
| ๐Ÿ”ด danger | โ‰ฅ10K | Emergency only |
| ๐Ÿ’€ hibernate | <10K | Minimal activity |

## Installation

```bash
# Link install
openclaw plugins install --link /path/to/moss-agent-loop

# Or manual: add to openclaw.json
{
  "plugins": {
    "entries": {
      "moss-loop": { "enabled": true }
    }
  }
}

# Restart gateway
openclaw gateway restart
```

## Inspired By

- [Conway Automaton](https://github.com/Conway-Research/automaton) โ€” Self-replicating AI agent with economic pressure
- [ClawWork](https://github.com/HKUDS/ClawWork) โ€” AI agent economic benchmark

## License

MIT
tools

Comments

Sign in to leave a comment

Loading comments...