Editing Before Continuing
Human corrections.
Sometimes the action is nearly right. The customer asked for twenty copies, but meant two. Instead of rejecting, staff can edit the details, and let the agent carry on.

- Nearly right
- Edit, don't reject
- Then carry on
Correcting the quantity
The customer asks for twenty copies of Circe. The graph pauses. Staff resume with an edit, setting the quantity to two. The tool uses the edited quantity. Run it. The paused request shows twenty, but the tool result shows two copies ordered.
from langgraph.types import Command
from order_agent import graph
config = {"configurable": {"thread_id": "order-2"}}
ask = {"messages": [{"role": "user", "content": "Order 20 copies of Circe."}]}
paused = graph.invoke(ask, config)
print("requested:", paused["__interrupt__"][0].value)
done = graph.invoke(Command(resume={"type": "edit", "quantity": 2}), config)
print("tool result:", [m.text for m in done["messages"] if m.type == "tool"][-1])requested: {'action': 'place_order', 'title': 'Circe', 'quantity': 20}
tool result: Ordered 2 x Circe.Also uses order_agent.py
from langchain.chat_models import init_chat_model
from langchain.tools import tool
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import MessagesState, StateGraph, START
from langgraph.prebuilt import ToolNode, tools_condition
from langgraph.types import interrupt
@tool
def place_order(title: str, quantity: int) -> str:
"""Place an order for copies of a book."""
decision = interrupt({"action": "place_order", "title": title, "quantity": quantity})
if decision["type"] == "reject":
return "Order rejected by staff."
if decision["type"] == "edit":
quantity = decision["quantity"]
return f"Ordered {quantity} x {title}."
model = init_chat_model("google_genai:gemini-flash-lite-latest", temperature=0).bind_tools([place_order])
def agent(s: MessagesState):
return {"messages": [model.invoke(s["messages"])]}
b = StateGraph(MessagesState)
b.add_node(agent); b.add_node("tools", ToolNode([place_order]))
b.add_edge(START, "agent"); b.add_conditional_edges("agent", tools_condition); b.add_edge("tools", "agent")
graph = b.compile(checkpointer=InMemorySaver())Approve, edit, reject
With one interrupt and a decision dictionary, you support all three choices. Approve runs as planned. Edit changes the arguments. Reject returns a message to the model, so the agent can explain to the customer. LangChain's human in the loop middleware uses this same idea.
| key | value |
|---|---|
| approve | run as planned |
| edit | change arguments |
| reject | tell the model |
| Middleware | same idea |
Summary
Resume with an edit, and the tool uses the corrected details. One decision dictionary supports approve, edit, and reject. Next, practise with a refund approval graph.
Key takeaways- {'type': 'edit', ...}
- Tool uses new values
- Approve, edit, reject