Approval waiting and replay
A managed Agent can wait in the running process or return a waiting thread for your code to resume. With a direct Python client, your code polls and replays the request.
On this page
Wait for approval with a managed AgentReplay an approved request with a direct Python clientRecover after a process restartWait for approval with a managed Agent
During an in-process wait, LangChain and Deep Agents pause the tool call when a Decision requires approval. The SDK polls for the reviewer’s decision and replays the original request after approval. The tool can run only after successful revalidation.
| Setting | Default | Purpose |
|---|---|---|
timeout | 3,600 seconds | Maximum local wait |
poll_interval | 0.5 seconds | Initial poll interval |
poll_backoff_multiplier | 2 | Interval growth between polls |
poll_max_interval | 5 seconds | Maximum polling interval before jitter |
poll_jitter | 0.1 | Random variation of up to 10% in either direction |
timeout limits how long the Agent waits locally. The request has its own expiry in the Console and may still be pending when the local wait ends. When the wait ends on timeout, rejection or expiry, the tool does not run. A later approval cannot restart a timed-out call. The default on_block="message" returns an error tool message. With on_block="raise", the SDK raises ApprovalTimeout on timeout or BlockedError on rejection or expiry.
To change the local wait, pass ApprovalConfig when creating your Agent.
import os
from openeight import OpenEightConfig
from openeight.langchain import ApprovalConfig
openeight_config = OpenEightConfig(
agent_name=os.environ["OPENEIGHT_AGENT_NAME"],
endpoint=os.environ["OPENEIGHT_ENDPOINT"],
credential=os.environ["OPENEIGHT_API_KEY"],
approval=ApprovalConfig(timeout=120.0), # Wait up to two minutes instead of one hour.
)
# Pass openeight_config to create_agent or create_deep_agent.
Expected result · This Agent waits up to two minutes for review.
Replay an approved request with a direct Python client
Your code owns the wait. Before calling client.decide, snapshot the full tool arguments and save the exact request, including the Run ID, Decision ID, tool version, source time, policy digest and selected values.
- Check that the response matches the original Run and Decision IDs. An initial allow authorizes this attempt. For
approval_required, set a local deadline. Before each poll, calculate the time remaining and pass it toclient.approval_state(decision_id, timeout=remaining). Stop when the deadline passes. - After observing
approved, recalculate the remaining time. If time remains, replay the saved request withclient.decide(**request, timeout=remaining). Check that both IDs match,replayedis true and the verdict isalloworapproval_required. The recorded Decision can retain its original verdict after approval. - Check the deadline once more before calling the handler with the saved arguments. On rejection, expiry, timeout, a mismatched response or failed revalidation, stop. If the outcome is uncertain, reconcile the original attempt before retrying.
Recover after a process restart
If a durable Agent returned waiting, reopen it with the same durable state after restart. Once the reviewer responds, call resume(thread_id=thread_id, command_id=command_id) or aresume with the original thread ID and a new command ID for the resume operation. Reuse that command ID if you retry the same operation.
Configure durable recovery before starting the Run. It requires persistent storage, exclusive access to the thread and a way to check whether the destination already executed the tool. An in-process wait ends when the process exits.
For LangChain durable model and schema settings, use an immutable DurableApprovalConfig.deployment_binding with bind_deployment or abind_deployment.
For Deep Agents, finish outstanding format-1 approvals with their original runtime, artifact, configuration and credential. Start format-2 deployments with fresh state. Credential rotation or rebinding requires a migration.