What's Happening (Mental Model)
Here's the mental model for how a request flows through m4trix:
Flow Overview
HTTP Request — A client sends a POST (or GET) to your exposed endpoint.
expose() — Extracts the JSON payload, runs auth (if configured), and publishes a start event to the main channel.
Main Channel — Events enter here. Agents subscribed to this channel receive the event.
Agent(s) — Logic runs. The agent reads
triggerEvent.payload, does work (e.g. calls an LLM), and emits new events.Client Channel — Emitted events are published to channels the agent is bound to. The client channel has an
httpStream()sink, so events are streamed as SSE to the browser.Browser — Receives SSE events and can render them in real time.
Key Ideas
Events are typed messages. Schemas are validated at runtime via Effect.
Channels route events. Agents subscribe to channels (input) and publish to channels (output).
Sinks determine how events leave the system — e.g.
httpStream()for SSE, or Kafka for event backends.AgentNetwork wires everything: channels, agents, and the event plane.
Diagram
Next
Next Steps — Where to go from here
Last updated