Skip to main content

Body guide

A Plexa body is a class. It declares its tools, runs a tick loop, emits events, and optionally listens for events from peer bodies.

Minimal body

That is a complete body. Add it to a Space and the brain can call any of the three tools.

static tools

Each tool needs a description and a parameters schema. The schema fields Plexa understands:
The translator rejects intents that violate the schema and emits intent_error. Stats track rejections by reason in space.getStats().translator.byReason.

tick()

The Space calls tick() on every body each frame at tickHz. Use it to read sensors and update state.
Always call super.tick(). Stats and counters live in the base class.

emit() with priority

Priorities are CRITICAL, HIGH, NORMAL, LOW. The aggregator drops events in reverse priority order when the prompt approaches the token budget; CRITICAL events are preserved.
Subscribe at the Space level:

onPeerEvent for lateral events

Bodies can talk to each other directly. Override onPeerEvent and link the two bodies in the Space.
To send from inside another body’s tick:
Direct in-process call. Plexa is not in the routing path. Self-links are silently ignored so you cannot accidentally infinite-loop a body.

Full working example

Python bodies

A body in Python coordinates with Plexa over HTTP. Plexa auto-wraps a class declaration like this and talks to the Python process through the network body contract.
The Python side exposes:
  • GET /discover returns { tools: { ... } }
  • GET /health returns { ok: true }
  • GET /state returns { data: { ... } }
  • GET /events drains { events: [...] }
  • POST /tool accepts { name, parameters }
The MuJoCo adapter in the SCP repo is a working example.