πŸ“¨ RelayKit

RelayKit is a policy-safe communications runtime for developers building customer-facing AI agents.

Giving a model access to an inbox is easy. Letting it safely represent a company is not. Real customer communication requires identity, durable threads, business context, permissions, approval boundaries, delivery handling, human escalation, and a record of every source and action.

RelayKit packages those missing pieces into an installable TypeScript SDK and hosted control plane.

🧩 Developer experience

A developer defines the transport, company knowledge, available tools, and explicit action policy:

export default defineSupport({
  transport: agentMail({
    inbox: "[email protected]",
  }),

  knowledge: [
    website("https://moltencoffee.shop"),
    document("./support-policy.md"),
  ],

  tools: [
    shopify.orders.read(),
    shopify.addresses.update(),
    shopify.refunds.prepare(),
  ],

  policy: {
    automatic: ["faq", "order_status"],
    approvalRequired: ["refund", "cancel_order", "change_address"],
    prohibited: ["invent_product_claim", "override_refund_policy"],
  },
});

RelayKit provisions the inbox workflow, normalizes incoming messages, maintains the conversation, gathers customer context, runs the agent inside declared policy, and returns one of four outcomes:

  • Respond β€” safely answer using supported company knowledge
  • Act after approval β€” prepare a sensitive tool action and wait
  • Escalate β€” hand the case to a human with a complete summary
  • Clarify β€” ask the customer for required information

🧠 System architecture

 Customer email
      β”‚
      β–Ό
 AgentMail / Resend Transport Adapter
      β”‚
      β–Ό
 Webhook Verification, Dedupe & Message Normalization
      β”‚
      β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ί Durable Thread + Customer Identity Store
      β”‚                                   β”‚
      β–Ό                                   β–Ό
 GPT-5.6 Conversation Planner ◄── Knowledge & Business Context
      β”‚
      β”œβ”€β”€β”€β”€β”€β”€β”€β”€β–Ί Policy Runtime ────────► Allow / Approve / Deny
      β”‚                                      β”‚
      β”œβ”€β”€β”€β”€β”€β”€β”€β”€β–Ί Business Tools              β–Ό
      β”‚          Shopify β€’ CRM β€’ billing   Human Approval Queue
      β”‚                                      β”‚
      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β–Ό
                    Reply / Action Executor
                             β”‚
                             β–Ό
                   AgentMail Threaded Reply
                             β”‚
                             β–Ό
              Trace, Replay, Metrics & Human Handoff

πŸ” Policy before autonomy

RelayKit does not use an unexplained model percentage to decide whether a refund is safe. Developers express business boundaries directly.

Each case records:

  • The matched policy rule
  • The sources used in the response
  • The customer and order context supplied to the model
  • Every proposed and completed tool call
  • The approval identity and timestamp
  • The exact outbound message
  • Delivery and reply events

This makes customer-service automation testable and reviewable instead of magical.

πŸ”„ Complete communications lifecycle

Receive

  • Verify inbound webhooks
  • Deduplicate retried events
  • Normalize provider-specific payloads
  • Extract clean replies, attachments, and participants
  • Reconstruct the correct conversation thread

Understand

  • Resolve the customer identity
  • Retrieve prior conversation memory
  • Load the relevant company policy and storefront knowledge
  • Fetch current order, billing, or account context

Decide

  • GPT-5.6 plans the response and any required tools
  • The policy runtime evaluates the requested action
  • RelayKit automatically responds, pauses for approval, asks a question, or escalates

Act

  • Run only permitted tools
  • Keep actions idempotent
  • Send the response inside the original thread
  • Handle provider delivery events and failures

Observe

  • Display a structured trace
  • Replay a case using a new policy or agent version
  • Compare the proposed response before deploying changes
  • Export a complete handoff summary for a human agent

πŸ§ͺ Support simulator

Developers should not test customer-service agents on real customers.

RelayKit includes scenario fixtures such as:

scenario: late-order-then-refund
messages:
  - "Where is order MC-1042?"
  - "It will arrive too late. Please refund it."
expected:
  first_message: automatic_response
  second_message: approval_required
prohibited:
  - refund_without_approval
  - unsupported_delivery_promise

The simulator runs these conversations against the full knowledge, tool, and policy configuration and produces a pass/fail trace. Teams can run it locally or in CI before changing a prompt, model, policy, or integration.

β˜• Working demonstration: Molten Coffee

Molten Coffee is the first live demonstration company.

Scenario 1 β€” routine question

A customer asks when their coffee was roasted. RelayKit cites the storefront’s roasted-to-order information and answers automatically without inventing a fulfillment date.

Scenario 2 β€” order lookup

A customer emails, β€œWhere is my order?” RelayKit resolves the customer, retrieves the Shopify order, and replies in the same AgentMail thread with the current order status.

Scenario 3 β€” sensitive action

The customer requests a refund. RelayKit prepares the permitted refund operation and a response, then pauses in the approval queue. After the merchant approves it, the tool runs exactly once and the customer receives the final reply.

Scenario 4 β€” product-safety question

A customer asks a question that is not answered by the product catalog. RelayKit refuses to invent a product or health claim and escalates the thread with the missing information highlighted.

πŸ”Œ Provider architecture

AgentMail is the first provider because it supplies agent-owned inboxes, threads, replies, attachments, realtime events, and custom domains. RelayKit wraps it behind a transport contract:

interface CommunicationsTransport {
  verify(request: Request): Promise<VerifiedEvent>;
  normalize(event: VerifiedEvent): Promise<InboundMessage>;
  reply(threadId: string, message: OutboundMessage): Promise<Delivery>;
  subscribe(handler: EventHandler): Promise<Subscription>;
}

A Resend adapter can implement the same contract while RelayKit owns threading, deduplication, ordering, and reply state. Future adapters can bring SMS, chat, or WhatsApp conversations through the same policy and trace runtime.

🧱 Technical implementation

  • GPT-5.6: message understanding, grounded response planning, tool planning, clarification questions, and human-handoff summaries
  • Codex: TypeScript SDK, transport contract, webhook ingestion, idempotency, policy runtime, Shopify tools, trace viewer, scenario simulator, tests, and deployable sandbox
  • AgentMail: email inboxes, two-way threads, attachments, webhooks, and realtime events
  • Next.js + TypeScript: developer console, inbox, approval queue, and trace explorer
  • PostgreSQL: threads, customer identity, policy versions, approvals, and execution records
  • Shopify: real order context and controlled support actions for the Molten demonstration

🎬 Three-minute demo

  1. Run npx relaykit init and show the generated support configuration.
  2. Send a real customer email to the Molten support inbox.
  3. Watch RelayKit retrieve an order and reply in-thread.
  4. Request a refund and show the policy runtime pause the action.
  5. Approve it from the control plane.
  6. Show the final customer reply and replayable execution trace.
  7. Run the same scenario in the simulator to demonstrate how developers test policy changes.

πŸ† OpenAI Build Week

Track: Developer Tools

RelayKit is not another support chatbot. It is the runtime that makes customer-facing communication agents safe to integrate, test, observe, and extend.

Built With

Share this project:

Updates