Skip to main content
awp-python is the agent side of AWP. It provides awp, the client protocol layer described here. The reference world, awp-sim, is a separate package built on it. awp-python targets 0.1-draft.12 and requires Python 3.11+.
Alpha: the API changes with each draft revision. Its demo agent, awp-demo, is Core Agent (lockstep): AWP-conformant against 0.1-draft.12 (awp-conformance 0.1.0a10) and Core Agent (streaming): AWP-conformant against 0.1-draft.12 (awp-conformance 0.1.0a10) (reports).

Two layers

  • awp.ClientConnection is the protocol as a sans-IO state machine: it never opens a socket or reads a timer. Request methods queue messages and return the JSON-RPC id they used; receive(message) takes a decoded message and returns typed events; outgoing() drains what to send. Use it directly to run AWP over any transport, or inside a simulator loop.
  • awp.aio.AsyncClient drives a ClientConnection over the WebSocket binding (AWP-TRN-001) with asyncio. It adds transport, heartbeats, and awaiting; protocol behavior stays in the connection.

Streaming

open_session takes the four clock samples AWP-CLK-008 asks for before returning. submit returns once the world admits the action, raising AwpError if it refuses; the returned ActionRecord then follows every status the world reports.

Lockstep

Time moves only when the agent calls advance (world.tick), and never as a side effect of anything else (AWP-AGT-009):

Heartbeats

AsyncClient(heartbeat=True), the default, pings from a timer at the smaller of heartbeat_interval_ms and half the watchdog. In a streaming session, an agent that actuates something should pass heartbeat=False and call await client.ping() from the loop that produces its intents, so that a stalled policy also stops the heartbeat holding off the world’s watchdog (AWP-SAF-005). Lockstep has no watchdog, and under tick_authority: "barrier" an advance() waits for the other sessions (AWP-TIM-012), so the timer pings there regardless.

What the connection tracks

Events

receive() and AsyncClient.events() yield: Initialized, SessionOpened, SessionStateChanged, ActionUpdated, WorldEvent, FrameReceived, Telemetry, TickCompleted, ReplayCompleted, Response, ErrorResponse, and ProtocolViolation.

Without asyncio

Beyond Core

Stream connections. When session.ready offers a ws endpoint, AsyncClient connects to it with the session token and receives binary frames there; it re-establishes it if only the stream connection drops (AWP-TRN-010..013). AsyncClient(streams=False) keeps everything inline. Stream bindings other than ws are not covered.

Other modules

  • awp.frames — the binary frame codec (every vector in frames.json) and the inline JSON form.
  • awp.schema — validation against the canonical schemas bundled from the pinned revision, in receiver and sender form.
  • awp.lifecycle — ActionState and the transition table.
  • awp.errors — ErrorCode and AwpError, which carries retryable and data.