Sub topic 2
Approve, Reject, Edit, and Give Feedback
Assume you understand how an LLM agent calls tools, can read short Python programs, and know basic JSON and background jobs.
An approval step should support more than a yes-or-no answer:
- Approve: run the proposed action exactly as shown.
- Reject: do not run it. Store the reason so the agent or operator can respond appropriately.
- Edit: change permitted arguments, then review or validate the edited action before execution.
- Feedback: provide guidance without authorizing the action. The agent can revise its plan and submit a new request.
Treat an edit as a new action. Never silently replace the arguments that the reviewer saw.
def resolve(call, decision, tools):
action = decision["action"]
if action == "approve":
return tools[call.name](**call.args)
if action == "edit":
edited_args = decision["args"]
edited_call = ToolCall(call.name, edited_args)
return tools[edited_call.name](**edited_call.args)
if action == "reject":
return {"status": "rejected", "reason": decision.get("reason", "")}
if action == "feedback":
return {"status": "revise", "message": decision["message"]}
raise ValueError(f"Unknown decision: {action}")What to Show the Reviewer
A reviewer needs enough context to judge the action, not the entire conversation. Show:
- The requested goal and the agent’s short reason for the action.
- The tool name and every argument, including the target account, record, or recipient.
- The expected effect and whether the action is reversible.
- Relevant evidence, such as a file diff or affected record count.
- The risk level, required permissions, and any deadline.
- Clear controls for approve, reject, edit, and feedback.
Avoid showing only a natural-language summary. A summary can hide a dangerous argument. Render structured arguments in a stable format so reviewers can compare requests consistently.
Pausing and Resuming with Saved State
A workflow must persist its state before it waits. Save the run identifier, current step, proposed tool call, approval identifier, expiration time, and conversation or plan data needed to continue. A worker can then stop, and another worker can resume the run after the reviewer responds or the process restarts.
Use an approval identifier that is single-use. On resumption, load the saved request, validate its status and expiry, apply the decision, and record the result. If the request has expired, require a new approval rather than executing it.
PENDING = {}
def request_approval(approval_id, call, expires_at):
PENDING[approval_id] = {
"call": call,
"expires_at": expires_at,
"status": "waiting",
}
def resume(approval_id, decision, now, tools):
item = PENDING.get(approval_id)
if item is None or item["status"] != "waiting":
raise KeyError("Unknown or already resolved approval")
if now > item["expires_at"]:
item["status"] = "expired"
return {"status": "expired"}
item["status"] = decision["action"]
return resolve(item["call"], decision, tools)Exercise
Why should an edited approval request be treated as a separate action?
Show answer
Editing changes the tool arguments, so the original reviewer decision no longer describes exactly what will run.