Sub topic 5
Approve, reject, edit, and feedback
This chapter covers the decisions a reviewer can make at an approval gate and how the workflow handles each one. It assumes you can read short Python programs, know how an agent calls tools, and have seen the risk lookup and the basic gate from the earlier chapters.
The four decisions
A gate that only says yes or no forces reviewers into bad choices. If the agent's email is almost right, the reviewer must reject it and hope the agent retries well. Four decisions cover most cases.
| Decision | What the reviewer does | What the workflow does next |
|---|---|---|
| Approve | Accepts the call as shown | Runs the tool with the original arguments |
| Edit | Changes the arguments | Runs the tool with the new arguments |
| Reject | Refuses the call and gives a reason | Skips the tool and returns the reason to the agent |
| Feedback | Gives guidance without running anything | Sends the guidance to the agent so it can plan again |
Reject and feedback are close. In this chapter, a reject ends that action. Feedback tells the agent how to try a different approach.
Handling decisions in code
The gate from the previous chapter already handles approve, edit and reject. This version adds feedback and validates the decision before using it.
from dataclasses import dataclass
@dataclass(frozen=True)
class ToolCall:
name: str
args: dict
VALID_ACTIONS = {"approve", "edit", "reject", "feedback"}
def apply_decision(call, decision, tools):
action = decision.get("action")
if action not in VALID_ACTIONS:
raise ValueError(f"Unknown decision: {action!r}")
if action == "approve":
return {"status": "executed", "result": tools[call.name](**call.args)}
if action == "edit":
edited = ToolCall(call.name, decision["args"])
return {"status": "executed", "edited": True,
"result": tools[edited.name](**edited.args)}
# reject and feedback both skip the tool and tell the agent why
return {"status": action, "message": decision.get("reason", "")}
if __name__ == "__main__":
tools = {"send_email": lambda to, body: f"sent to {to}"}
call = ToolCall("send_email", {"to": "[email protected]", "body": "Hi"})
print(apply_decision(call, {"action": "approve"}, tools))
print(apply_decision(call, {"action": "edit", "args": {"to": "[email protected]", "body": "Hi"}}, tools))
print(apply_decision(call, {"action": "feedback", "reason": "Use the shared team inbox."}, tools))An unknown action raises an error. Treating a typo as approval would run a call nobody approved.
Returning decisions to the agent
The agent must see what happened. For a skipped call, return a result in the same slot the tool result would have occupied. Otherwise many model APIs report an error, because a tool call has no matching result.
For an edit, tell the agent that the arguments changed. If the agent believes it sent the original email, its later reasoning can be wrong. The edited: True flag in the code above is a minimal way to do this. A better result includes the arguments that actually ran.
Common errors
- Silent rejection. A reject with no reason leaves the agent guessing, and it often retries the same call. Require a reason, or at least pass one along when present.
- Unvalidated edits. An edited argument set is new input. Check it against the tool's schema before running it, just as you would check agent-generated arguments.
- Stale approval after an edit. An approval of the original call must not cover the edited call. The chapter on binding approval to the exact action shows how.
- Retry loops. If the agent keeps proposing rejected calls, cap the number of attempts and escalate to a person.
Exercise
A reviewer sees an agent's send_email call addressed to an external customer. The body is correct, but the recipient should be a different address. Which decision fits best, and what must the workflow tell the agent afterward?
Show answer
Edit fits best, because only one argument needs to change. The workflow should run the tool with the edited arguments and tell the agent that the arguments were changed and which values actually ran. The edited arguments should also be validated before execution, and any earlier approval must not be reused for them.
Exercise
Why should apply_decision raise an error for an unknown action instead of defaulting to approve?
Show answer
A default of approve would let a malformed or misspelled decision run a tool call nobody approved. Failing closed keeps the gate safe, so an unrecognized decision stops the call.