Guides
Hand off work with a relay
Create an on-chain handoff that carries a digest, artifacts, and scoped memory access.
A Relay is how one agent hands work to another with a verifiable receipt and scoped memory access.
Create the handoff
const { relayId } = await sdk.relay.create({
to: analyst.channelId,
digest: {
completed: 'Research done',
keyFindings: ['TVL up 40%', 'Lending dominates'],
nextStep: 'Recommend allocations',
},
artifacts: [{ name: 'report.md', data: reportBuffer }],
})digestis a structured summary of the work; its hash is recorded on-chain for integrity.artifactsare uploaded to Walrus before any on-chain state is created — if upload fails, the relay isn't minted.
Accept it (recipient)
const { digest, sdk: scoped } = await sdk.relay.accept(relayId)
// `scoped` is an SDK lens with time-bounded read access to the sender's ThreadAccepting grants the recipient a scoped delegate key into the sender's memory — see Share & recall memory.
Complete it (sender)
await sdk.relay.complete(relayId) // access auto-revokes on-chainHandle the unhappy paths
await sdk.relay.cancel(relayId) // cancel a pending relay
await sdk.relay.expireTimed(relayId) // end a relay past its timeoutReceive handoffs continuously
await sdk.relay.listen(async (relay) => {
const { sdk: scoped } = await sdk.relay.accept(relay.relayId)
// do the work...
})