AG2 group chats can include a human: the planner interacts with the admin to revise a plan, and only when the admin types Approve does the work move to the next step. That is the human-in-the-loop pattern for multi-agent work that changes files or spends money.
Before you start
You need a working AG2 group chat with a planner and at least one worker agent. Decide what counts as approval: the single word Approve, typed by the admin, is the convention in the AG2 examples.
Add the admin as an agent in the group chat
Add a UserProxyAgent as the admin to the group chat agent list, with a system message that says it is the human approver. Set the planner to present its plan to the admin first, and set the speaker selection so the admin is asked before the engineer starts.
Test the approval gate with a plan that needs a change
Start a chat with a request that needs a plan. When the planner presents it, reply with a change instead of Approve, and check the planner revises the plan. Then type Approve and check the engineer starts work. If work starts before approval, the speaker order is wrong.
Worked example: Plan approval for a fictional research group
The AG2 research example uses a planner, an engineer, an executor, a scientist and a critic. The table shows the approval flow for one request.
| Step | Who speaks | What happens |
|---|---|---|
| 1 | Planner | Presents a plan to find recent papers |
| 2 | Admin | Asks for a narrower topic |
| 3 | Planner | Revises the plan |
| 4 | Admin | Types Approve |
| 5 | Engineer | Starts fetching the papers |
Expected result (UNTESTED): the engineer does not start until the admin types Approve, and the revised plan is the one that runs. We checked the AG2 group chat research example, which describes the planner and admin approval flow, but we did not run the chat on this machine.
Limits
A human gate only works if the human reads the plan: approving without reading is the same as no gate. The chat also waits while the admin decides, so a slow approver stalls the whole group. Keep the plan short so it can be judged in one reading.
