Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 3 min read

Keeping approved replies unchanged across worker restarts

In oss-assist, a private tool I built for my own open-source work, an agent drafts replies and I review them in a note. A separate Temporal workflow posts approved replies. The awkward question was what happens after ap

In oss-assist, a private tool I built for my own open-source work, an agent drafts replies and I review them in a note. A separate Temporal workflow posts approved replies.

The awkward question was what happens after approval if a worker restarts. I did not want recovery to ask the model to write another reply. Even a reasonable rewrite would be a different action from the one I reviewed.

I ended up separating three things: proposing text, reading approval, and sending a specific body to a specific destination. That separation helped, but it also exposed a limit in my approval format.

The intended flow is simple:

model proposes a reply
        ↓
human edits the note and marks it approved
        ↓
scan Activity returns destination + parsed reply body
        ↓
workflow schedules a posting Activity with those values
        ↓
posting Activity reconciles or sends, then records the URL

The posting path does not call the model. β€œDeterministic” here describes the workflow decisions around recorded Activity results. The external HTTP request is still an Activity with failures and uncertain outcomes.

Suppose the synthetic reply is:

Thanks for the reproduction. I can reproduce this with retries disabled.

Once the scan Activity has completed and its result is recorded in workflow history, that parsed body becomes the input to the posting step. Replaying the workflow after a worker restart uses the recorded result. It does not reread the note or generate a replacement paragraph.

The timing matters. My current implementation reads a mutable note marked approved; it does not store a content hash at the moment I approve it. Editing that note before the scan completes can change what the scan captures. A new workflow execution also scans again. This gives me a stable execution snapshot after a completed scan, not a tamper-proof approval record bound to an immutable version.

For a stricter approval boundary, I would need to persist the approved destination and body as a versioned action, and invalidate approval when either changes. That is a design improvement, not a property I can claim for the current implementation.

Sending introduces a different problem. A worker can make a successful HTTP request and then fail before recording success. Retrying the request blindly can create another comment.

My posting Activity uses a local ledger keyed by draft page. Before posting, it saves an in-flight entry with a start timestamp. After obtaining a comment URL, it replaces that entry with the URL. If the ledger already contains a URL, it returns that result without posting again. Editing and reapproving a successfully posted page therefore does not turn it into a second send action.

If only the in-flight timestamp exists, the sender checks the destination for a recent comment by my account with matching text. Finding that comment lets it recover the URL instead of posting again. The original timestamp survives across later attempts; recovery does not move the search window forward and forget the earlier request.

I also keep posting and note updates separate. If the comment was posted but marking the note fails, the ledger can still prevent another send. A corrupt ledger stops posting rather than silently starting with an empty history.

The tests exercise these individual boundaries with fake senders: the ledger exists before the send, a completed page is not sent again after edits, an in-flight attempt retains its original timestamp, and corrupt ledger data prevents posting. These are specific checks, not a reliability percentage or an exactly-once proof.

There are unresolved cases. The ledger's in-flight entry does not preserve the original body. If a later run reads edited text while the previous send has an unknown outcome, matching the new body cannot reliably identify the old comment. A missing acknowledgement needs reconciliation against the original action, or manual resolution when the evidence is insufficient.

Comment lookup itself also has limits: visibility, query coverage, concurrent sends, and text matching are not a transaction with the remote API. I cannot turn this pattern into an exactly-once guarantee for arbitrary services.

The useful boundary for this tool is narrower: let the model propose, let me review, then carry the captured action through execution without asking the model to reinterpret it. Recovery still needs its own evidence. Preserving the approved words and proving that a send happened are two separate jobs.

πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.