Lacuna/Labs
conversation-aware-reply-drafting
light purple
#290 / 601

NAME

conversation-aware-reply-drafting — Draft a Sakura-voice reply tuned to the thread. Draft NEVER auto-sends.

SYNOPSIS

id conversation-aware-reply-drafting tier light-purple section §9. Light purple — cloud reasoning (51 baseline, 86 post-matrix) trigger event:new-buyer-message tools etsy/conversations, sakura/cloud-reason source new

DESCRIPTION

cloud reasoning writes or reasons over your real data. The 'sound like you, but cleaner' tier. Atlas-pair-trained on the operator's own voice.

Draft a Sakura-voice reply tuned to the thread. Draft NEVER auto-sends.

MECHANISM

PREfetchGUARDtier: light-purpleACTperformRESULTrenderON-ERRretry / esc
;;~ title    "Draft a reply to a buyer message"
;;~ author   "lacuna"
;;~ version  1
;;~ mode     automation
;;~ flavor   light-purple
;;~ id       conversation-aware-reply-drafting
;;~ trigger  event:new-buyer-message
;;~ touches  ()
;;~ summary  "Read the buyer's message thread, draft a Sakura-voice reply tuned to the context."

;; Triggered when a new buyer message arrives. Pulls the thread, hands
;; it to Sonnet via sakura/cloud-reason for a calibrated reply draft,
;; type-traps the output, surfaces the draft for the operator to send.
;; The draft NEVER auto-sends.

(cart 'conversation-aware-reply-drafting
  '((author    . "lacuna")
    (version   . 1)
    (read-only . #t)))

(define (start ctx)
  (let ((thread-id (ctx-get 'thread-id ctx)))
    (if (null? thread-id)
        (escalate 'missing-thread-id null)
        (next 'fetch ctx))))

(define (fetch ctx)
  (let ((thread-id (ctx-get 'thread-id ctx)))
    (act 'etsy/conversations (list thread-id) 'check-fetch)))

(define (check-fetch ctx)
  (let ((r (ctx-result ctx)))
    (cond
      ((null? r)                       (escalate 'no-thread null))
      ((eq? r 'rate-limited)           (after 30 'fetch ctx))
      ((eq? r 'auth-stale)             (escalate 'auth-relogin null))
      (else                            (next 'reason (ctx-set 'thread r ctx))))))

(define (reason ctx)
  (let ((thread (ctx-get 'thread ctx)))
    (act 'sakura/cloud-reason
         (list 'task 'draft-buyer-reply thread)
         'check-reason)))

(define (check-reason ctx)
  (let ((r (ctx-result ctx)))
    (cond
      ((null? r)                       (escalate 'cloud-empty null))
      ((not (string? r))               (escalate 'cloud-garbled null))
      ((eq? r 'cloud-quota-exhausted)  (escalate 'cloud-quota null))
      ((eq? r 'cloud-consent-required) (escalate 'cloud-consent null))
      (else                            (next 'announce (ctx-set 'draft r ctx))))))

(define (announce ctx) (done))

source: curator-web/src/scheme/carts/etsy/conversation-aware-reply-drafting.sks · 54 lines

EXAMPLES

Example forthcoming — docs/automations/examples.json entry editable in place.

TIER

light purple
cloud reasoning · cents per call

FITNESS

Almost there

Works on smaller shops too; the answer sharpens as you collect more sales.

SEE ALSO

HISTORY

canonical source: curator/docs/AUTOMATIONS-CANONICAL.md · §9-light-purple-cloud-reasoning-51-baseline-86-post-matrix
last regenerated: 2026-06-05 20:31 UTC (mechanical — edits land in the MD or sidecars, not here)

KNOWN BUGS

(none recorded — flag in AUTOMATIONS-CANONICAL.md or open an issue against the cart file)