Plan Mode
With permission_mode="plan", the agent proposes a plan and waits for approval before executing. Approve or ask for a revision. This is one of three human-in-the-loop mechanisms.
Approve a plan
Plan approval arrives as an AskUserQuestion titled Plan Approval. Use req.is_plan_approval and req.plan_text to detect and display it:
Python
from m8tes import M8tes
client = M8tes()
def handle_plan(req):
if req.is_plan_approval:
print(req.plan_text) # show the proposed plan
return {"Plan Approval": "Approve"} # or "Revise"
return {}
run = client.runs.create(agent_id=1, message="reorganize open support incidents",
human_in_the_loop=True, permission_mode="plan", stream=False)
# wait() handles the plan pause and then continues with approval-style checks
run = client.runs.wait(run.id, on_question=handle_plan, on_approval=lambda req: "allow")
print(run.output)After approval, execution continues with approval-style checks for non-safe tools. Plan approvals never auto-continue: the run waits for a decision. See examples/plan-mode.py for a complete interactive example.
Embed plan approval in your product (polling flow)
Fetch the plan text and show it to your user before answering:
Python
import time
run = client.runs.create(agent_id=1, message="...", human_in_the_loop=True,
permission_mode="plan", stream=False)
while run.status == "running": # poll until the plan is ready
time.sleep(2)
run = client.runs.get(run.id)
for req in client.runs.permissions(run.id): # get the plan text
if req.is_plan_approval and req.status == "pending":
plan_text = req.plan_text
# show plan_text in your UI, collect the decision, then answer and finish
client.runs.answer(run.id, answers={"Plan Approval": "Approve"})
run = client.runs.poll(run.id)
print(run.output)Prefer webhooks over polling in production: subscribe to run.awaiting_input and answer from your UI. See Human-in-the-Loop.
Next: Human-in-the-Loop · Runs
Was this page helpful?