AI AgentsAI Agent Execution & Lifecycle
How can you inspect and steer a paused AI agent?
Question 271 of 280 · Updated
On this page
- 1. What should be visible when an agent pauses?
- 2. Inspect the checkpoint, not just the conversation
- 3. Steering options: approve, reject, edit, or redirect
- 4. Beginner-friendly production example
- 5. A safe pause–inspect–steer–resume lifecycle
- 6. LangGraph implementation pattern
- 7. What can go wrong?
- 8. Observability and operating metrics
- 9. Engineering trade-offs
- 10. Common mistakes to avoid
- 11. How this differs from related agent concepts
A paused AI agent should be treated as a live, recoverable workflow with a reviewable state, not as a chat transcript waiting for someone to type “continue.” Inspecting it means understanding exactly what the agent has completed, what it is waiting for, which actions are pending, and what evidence supports its current state. Steering it means making a bounded, authorized change—such as approving, rejecting, correcting an input, narrowing scope, or changing the next step—and then resuming the same execution safely.
The key is to preserve the relationship between the reviewed state and the action that eventually runs. A human should never approve an ambiguous summary and unknowingly authorize a different tool call after the agent has changed its plan.
1. What should be visible when an agent pauses?#
A useful operator view combines five kinds of information:
- Run identity and status: tenant, task/run ID, thread ID, current status (running, interrupted, waiting for approval, failed, cancelled), creation time, last checkpoint version, and pause reason.
- Execution position: completed steps, current node/phase, pending steps, retry count, deadline, and whether the workflow can be resumed or must be restarted.
- Current state: the task objective, constraints, relevant structured state, and a concise summary of decisions already made. Show source references and timestamps for important facts.
- Pending action: tool name, exact arguments, target resource, environment, estimated impact, permissions required, and whether the action has already been attempted.
- Evidence and history: recent tool results, validation outcomes, errors, prior approvals, state changes, and an append-only audit trail.
Do not expose the entire internal prompt or every raw tool result by default. Present a least-privilege projection that gives the reviewer enough evidence to decide. Keep sensitive fields masked and provide controlled drill-down where authorized.
2. Inspect the checkpoint, not just the conversation#
A transcript can say “I will delete the old records,” but it does not prove which records are in the pending tool call. The orchestrator should load the durable checkpoint associated with the exact run/thread identifier and expose a typed state snapshot.
For each review, answer these questions:
- What is the agent trying to achieve? Show the original goal and machine-checkable acceptance criteria.
- What has actually happened? Separate completed and independently verified effects from intentions or model-generated claims.
- What is pending? Identify the exact tool call or next transition, including arguments and target scope.
- What is uncertain? Mark stale, missing, or unverified evidence explicitly.
- What can the reviewer change? List allowed operations and their consequences.
- What will happen after resume? Show the next node/action and the conditions that will be revalidated.
In LangGraph, a durable checkpointer stores graph state and associates it with a stable thread_id. An interrupt() can surface a JSON-serializable review payload; the caller can inspect the interrupt and later resume with Command(resume=...). State history and snapshots can also be used to inspect prior steps. The exact API and streaming projection depend on the LangGraph version, so pin and test the version used in production.
A checkpoint is not automatically a complete audit record. Store external evidence and large artifacts separately, then reference immutable versions or content hashes from the state.
3. Steering options: approve, reject, edit, or redirect#
A review interface should offer explicit, typed decisions rather than a free-form “continue” button:
- Approve: authorize the exact pending action, with the approved scope and expiry recorded.
- Reject: block the action and either terminate the run or route it to a safe alternative.
- Edit: correct a parameter, narrow a target list, or supply missing information. Revalidate the edited state before execution.
- Redirect: change the next permitted workflow step, provided the new route is part of the agent's allowed policy.
- Hold or cancel: keep the workflow paused, or terminate it and revoke outstanding action tokens.
Approval must be bound to the reviewed action version. If the tool name, arguments, target set, environment, or relevant evidence changes after review, invalidate the old approval and request a new one. A reviewer approving “archive 42 inactive accounts” must not accidentally authorize “delete 420 accounts.”
Use role-based authorization and separation of duties for high-impact actions. A person who can inspect a run need not automatically be allowed to approve payments, delete data, or change tenant boundaries.
4. Beginner-friendly production example#
Imagine a CRM agent asked to identify and archive inactive trial accounts. The agent queries the CRM and prepares a candidate set of 180 accounts.
Before any write operation, the workflow pauses and presents:
- Run:
crm-cleanup-7842 - Tenant:
tenant-17 - Proposed action: archive accounts (not permanently delete)
- Candidate count: 180
- Rule: no login or purchase in the last 180 days
- Evidence: query timestamp, CRM snapshot/version, and candidate-list checksum
- Status: awaiting review; no archive operation has run
A reviewer inspects the sample and discovers that 8 accounts belong to a protected customer cohort. They edit the scope to exclude those accounts and approve the remaining 172.
The agent revalidates the exclusion rule against the current CRM data. During the review, another 2 accounts become active. The final eligible set is therefore 170, not 172. The agent displays the changed count and requires renewed approval because the reviewed action changed materially. The reviewer approves the exact 170-account set.
Execution then archives 170 accounts in batches of 25: six batches of 25 and one batch of 20. The workflow records each batch result and an idempotency key. If the worker crashes after the fourth batch, it checks the CRM's operation ledger before retrying. It does not blindly replay the first 100 records.
This example illustrates the core rule: a human decision authorizes a specific, versioned action—not an open-ended instruction to let the agent do whatever it decides next.
5. A safe pause–inspect–steer–resume lifecycle#
- Pause at a deliberate boundary. Prefer pausing before an irreversible or high-impact side effect. Do not assume a process can be safely stopped halfway through an external API operation.
- Persist a consistent checkpoint. Record the workflow position, structured state, pending action, relevant evidence references, and state version. Use durable storage in production.
- Publish a review request. Include a stable run ID, action ID, action version, exact scope, risk, and an expiry. Avoid relying on a worker's in-memory state or an open HTTP request.
- Authorize the reviewer. Verify identity, tenant, role, separation-of-duty rules, and permission for this action and environment.
- Apply a typed decision. Validate the response schema, allowed values, reviewer authority, and approval expiry. Record the reviewer and decision.
- Revalidate before execution. Recheck resource versions, policy, permissions, evidence freshness, and action arguments. If material facts changed, pause again for approval.
- Resume the same run. Use the same durable thread/run identity and the framework's documented resume mechanism. Do not create a new run that silently loses the paused state.
- Verify the outcome. Read back the external system's state, compare it with the approved scope, and record successes, failures, and skipped items.
- Close or escalate. Mark the run completed, rejected, expired, cancelled, or blocked. A timeout must never silently become approval.
6. LangGraph implementation pattern#
A simplified Python sketch shows the control flow. The production implementation must persist state with a durable checkpointer and use an authenticated API around review and resume.
PYTHONfrom langgraph.types import interrupt, Command def review_pending_action(state): # Build a stable, versioned proposal from structured state. proposal = { "run_id": state["run_id"], "action_id": state["pending_action"]["id"], "action_version": state["pending_action"]["version"], "tool": state["pending_action"]["tool"], "arguments": state["pending_action"]["arguments"], "evidence_hash": state["pending_action"]["evidence_hash"], "allowed_decisions": ["approve", "reject", "edit"], } # Execution pauses here; the caller receives the review payload. decision = interrupt(proposal) # Validate the decision and bind it to the exact proposal version. validate_reviewer_decision(decision, proposal) return {"review_decision": decision} # Initial execution uses a stable thread_id and a durable checkpointer. config = {"configurable": {"thread_id": "crm-cleanup-7842"}} result = graph.invoke(initial_state, config=config) if result.get("__interrupt__"): publish_review_request(result["__interrupt__"]) # Later, after authenticating and validating the reviewer: resume_result = graph.invoke( Command(resume=validated_decision), config=config, )
Important framework behavior: when a LangGraph interrupt resumes, the node containing interrupt() starts again from its beginning. Code before the interrupt can run again. Keep that code deterministic and free of non-idempotent side effects; put external writes after the approval gate, and protect them with idempotency keys and independent reconciliation. Do not swallow the framework's interrupt exception in a broad try/except.
For state inspection, expose a read-only operator endpoint that retrieves the snapshot/history for the authorized thread. For steering that requires editing checkpoint state, use a narrowly scoped, audited operation and validate the resulting state before resuming. Do not let a browser directly mutate arbitrary serialized graph state.
7. What can go wrong?#
- Approval applies to a changed action: the model revises arguments after the reviewer approves. Bind approval to action ID, version, arguments hash, and target scope; invalidate it on material change.
- Side effect happens before pause: the workflow pauses after sending a payment or deletion request. Put the gate before the side effect; if outcome is uncertain, reconcile with the external system before retrying.
- Duplicate resume requests: a double-click or queue retry resumes the same run twice. Use a one-time decision/transition ID, compare-and-swap state version, and idempotent resume endpoint.
- Node replay repeats earlier work: code before
interrupt()runs again. Keep it pure or idempotent; never put a charge, deletion, email send, or external write before the interrupt in that node. - Stale checkpoint: the external resource changed while the agent waited. Re-read current versions and re-evaluate preconditions; ask for fresh approval if the action changed.
- Wrong thread or tenant: an operator resumes a different run or crosses tenant boundaries. Authorize every inspect, edit, and resume request against tenant and run ownership.
- Reviewer response is malformed or unauthorized: validate schema, allowed decision, reviewer role, and approval scope server-side. Never trust a UI-only disabled button.
- Reviewer never responds: define expiry, escalation, and cancellation behavior. Keep the action blocked; do not infer consent from silence.
- Checkpoint leaks secrets: store only what is required, encrypt sensitive state, mask operator views, and apply retention/deletion policies.
- Agent changes direction after resume: enforce policy and action validation again at execution time. A prior approval is not blanket permission for later actions.
8. Observability and operating metrics#
Track the pause lifecycle as a first-class workflow state:
- Number of paused runs by reason, tenant, tool, and risk level.
- Median and p95 time waiting for review.
- Approval, rejection, edit, expiry, and escalation rates.
- Percentage of approvals invalidated because the action or evidence changed.
- Duplicate resume attempts and idempotency conflicts.
- Checkpoint save/load failures and stale-state revalidation failures.
- Side effects attempted without a valid approval (target: zero).
- Difference between approved scope and actual external outcome (target: zero unexplained differences).
Alert on long-lived high-risk pauses, repeated resume conflicts, missing audit records, and any protected action executed without a valid approval. Avoid optimizing only for fast approval: a low review time can indicate that reviewers are rubber-stamping requests.
9. Engineering trade-offs#
- Human review vs autonomy: review improves control but adds latency and operational cost. Reserve mandatory gates for high-impact, uncertain, or policy-sensitive actions; let low-risk reversible work proceed under bounded permissions.
- Full state exposure vs curated snapshots: full snapshots help debugging but can expose secrets and overwhelm reviewers. Default to a concise, typed projection with audited drill-down.
- Checkpoint frequency vs storage overhead: frequent checkpoints reduce recovery work but increase write volume and retention cost. Save at meaningful boundaries and before risky operations.
- Edit checkpoint vs provide resume input: a typed resume decision is easier to validate and audit. Direct state edits are more flexible but should be rare, privileged, versioned, and followed by invariant checks.
- Wait indefinitely vs expire: indefinite waits preserve the opportunity for review but accumulate stale runs. Expiry and escalation improve operations, while still keeping protected actions blocked.
10. Common mistakes to avoid#
- Treating a transcript or model-generated status message as authoritative execution state.
- Showing “Approve” without displaying the exact action, target, environment, and evidence.
- Reusing an approval after changing tool arguments or scope.
- Resuming with a new thread ID and losing the original checkpoint.
- Assuming a pause rolls back an external side effect that already happened.
- Retrying a timed-out write without checking whether it succeeded.
- Allowing anyone who can view a run to modify or resume it.
- Keeping a worker, web request, or browser session alive just to wait for a human.
- Making every tiny step require approval, which trains reviewers to click through.
- Failing to record who changed the state, what changed, why, and which checkpoint was resumed.
11. How this differs from related agent concepts#
- Q54, resuming interrupted tasks: focuses on recovering work after interruption. This lesson focuses on operator visibility and deliberate intervention while a run is paused.
- Q55 and Q151, checkpointing: explain what checkpoints are and why they improve reliability. Here, the checkpoint becomes an inspectable and steerable control surface.
- Q154, pausing for human approval: explains the approval gate. This lesson goes further into state inspection, evidence presentation, bounded edits, action-version binding, safe resume, and operator controls.
- Q267, validated agent loops: defines how actions and completion are validated. This lesson covers the human-operated control point during execution.
- Q270, context compaction: reduces active context while preserving task continuity. It does not authorize or steer a paused execution.
In short: inspect the durable, versioned execution state; show the exact pending action and evidence; accept only an authenticated, typed, scope-bound decision; revalidate before acting; resume the same run idempotently; and audit the outcome. A paused agent should be controllable without making its execution state ambiguous.
References
- 1.LangGraph interrupts and resumable executiondocs.langchain.com
- 2.LangGraph human-in-the-loop conceptslangchain-ai.github.io
- 3.LangGraph interrupt referencereference.langchain.com
- 4.LangChain human-in-the-loop tool reviewdocs.langchain.com
Related questions
Explore other topics:Large Language ModelsRetrieval-Augmented GenerationMLOps