The comparison
Start with relay
Relay is the shorter path and the one the Quick start uses. Your backend already authenticates your users; it makes the call and tells us who it is acting for. Nothing to host to begin with — though the moment the agent calls your backend, you host a mint endpoint (see below). Choose relay when the channel is not a browser you control — a Slack bot, an inbound email handler, a nightly job — or when you want your backend in every path for logging, policy, or rate control.Move to direct for a product UI
Direct removes the hop: the browser talks to us with a token your backend signed and we verified. Your workspace key never leaves your servers, and the token expires in minutes. The cost is infrastructure. You generate a keypair, publish a JWKS document, and add an endpoint that mints tokens for signed-in users.What actually differs at runtime
Only the provenance of the subject. In relay we trust what your backend asserts; in direct we verify a signature. Everything downstream — thread scoping, memory, traces, gates — behaves identically.You can run both
They are not exclusive. A product with a web chat and a Slack bot uses direct for the first and relay for the second, against the same agent. Threads stay separate because the subjects differ —user_9f2 and slack:T04AB:U0APP are different partitions.
When the agent calls your backend
This is where relay stops being “nothing to host.” When a wired patch calls an endpoint you run, the egress request carries two things: aPatchwork-Signature over your request secret — verified the same way in both modes — and a short-lived subject token, so your endpoint knows who it is acting for.
Where that token comes from is the difference:
- Relay — Patchwork holds no token, so it mints one by POSTing to your connection’s mint endpoint. That endpoint is the one thing a relay integration hosts.
- Direct — Patchwork reuses the session token the browser already presented; no extra call.