Skip to main content
Back to Community & Earn Hub
Q&A Questionai-agents +150 pt Bounty

Human-in-the-Loop Escalation for Long-Running Agents: Designing Async Voice/Push Interrupts Without Losing Execution State

@ethan_miller3 days ago 1752 views

We're building a long-horizon computer-use / DevOps agent that runs 15–45 minute tasks in the background.

Inevitably, the agent hits a blocking human gate:

  • A vendor dashboard asks for an SMS 2FA code.
  • A migration script touches a production table and needs explicit sign-off.
  • Two valid pricing tiers exist and the user didn't specify one.

Right now, keeping a Python asyncio coroutine + Playwright browser session open waiting on an HTTP webhook times out our worker pods or wastes idle container memory if the user takes 30 minutes to reply to a Slack push or phone call.

How are teams architecting durable suspend-and-resume for async human-in-the-loop escalations?

1 Answers

Community Answers

@noah_goldstein Accepted Answer2 days ago

Never hold an active worker pod or open WebSocket blocked for 30 minutes waiting on a human. Model the escalation as a durable state-machine checkpoint (Temporal, LangGraph PostgresSaver, or Redis + worker queue):


1. Emit ApprovalRequested & Persist Full Checkpoint

When the agent calls request_human_input(prompt, channel="voice|push|slack"):

  1. Serialize the message history, pending tool_call_id, and browser/VM snapshot ID to Postgres/Redis under run_id.
  2. Fire an async notification (Twilio/LiveAgent voice call, Web Push, or Slack interactive block) with a signed one-time resume_token.
  3. Exit the worker process immediately (zero idle compute burned).

2. Resume via Webhook / Voice Transcript

python
@router.post("/runs/{run_id}/resume")
async def resume_agent_run(run_id: str, payload: HumanDecision):
    state = await checkpoint_store.load(run_id)
    # Inject human reply as the tool result for the suspended tool_call_id
    state.messages.append({
        "role": "tool",
        "tool_call_id": state.pending_tool_call_id,
        "content": f"Human approved/answered via {payload.channel}: {payload.answer}",
    })
    await task_queue.enqueue("run_agent_turn", run_id=run_id)
    return {"status": "resumed"}

Add a TTL timeout (e.g. 2 hours) so unanswered escalations cleanly transition to timed_out and release any held sandbox snapshots.

Have a solution or working configuration?

Sign in or create a free account to answer this question (+10 pts, +25 pts if accepted) and tag helpful AIStoreHub repositories.