Core invariant. Cross-request state can only exist in Layer 2. Both the harness and the engine
are pure functions / stateless objects: the same input always produces the same result.
registry.py provides load_harness(name) / load_engine(name), so the bridge never directly
imports a concrete implementation — this is how “the three layers only pass values downward” is
realized in code.
Layer 1 · Harness
Each harness plugin is a pure stateless function:parse(raw) → TelosIR. It splits the user envelope,
moves large docs into the ref-pool, and bands every block PIN / FOLD / DROP.
The three built-in harnesses differ mostly in wire shape and identity markers:
| OpenClaw | Hermes | Telos | |
|---|---|---|---|
| Wire shape | Anthropic /v1/messages | Anthropic /v1/messages | OpenAI ChatCompletions |
| Identity markers | default / fallback | <system-reminder>, <command-message>, thinking blocks, the Claude Code tool set | standalone transport |
source_tag prefix | openclaw/* | hermes/* | telos/* |
Layer 2 · Bridge
One instance per session, stateful. It exposes five primitives —place, pin, mark, fold,
refresh — and runs canonicalization plus the §5 invariant check before every emit:
required), and the tool array
(source_rank, mcp_server, name). Cross-turn state lives in BridgeSessionState; see
Multi-turn state.
Layer 3 · Engine
Stateless and capability-aware. The bridge programs only against the abstractEngineAdapter
interface and never branches by engine name:
capabilities → EngineCapabilitiesplan_marks(ir) → EmitPlan— decides the anchor positionsemit(ir, plan) → wire dictparse_usage(response) → UsageReport
BidirectionalEngineAdapter (cache probe, span eviction, fork-and-replace). The bridge relies on
isinstance to guarantee it never calls a bidirectional method on a closed-source API.
Full architecture reference
Every data structure, primitive, engine strategy, invariant, and extension point — the authoritative
deep dive.
The orthogonal second line · RTK
What TELOS stabilizes is the request prefix. Each turn the agent also appends large chunks of tool output to the tail. The RTK output filtering layer compresses that repetitive tail — an independent optimization controlled by the same four-stateTelosMode switch.