
To build an AI agent with an approval step, start with one small job. This project reads a fictional library notice and drafts an answer. You see the full draft before you can save it. If you say no, the script writes no file.
Build an AI agent around one task
Our sample asks when the Cedar Branch library workshop starts and if guests need to book. The source holds two facts. The event starts at 10 a.m. and booking is required. The AI agent architecture guide shows the full set of parts that can check, review and save a draft.
Give the agent just the tools it needs. For this project, it needs one source to read and one place to put the approved draft. It does not need a web search, a mail app or a tool that can edit the notice. Use the AI agent permissions matrix to make those choices before you add tools.
Run the Python quick start
Use Python 3.10 or newer. Make a new folder and save the code in this guide as public-demo.py. Open a terminal in that folder and run python public-demo.py. The code uses a fixed template in place of a model and never opens the fictional link in the source.
If you need to install Python first, follow the official Python setup instructions for your operating system.
Show the Python quick start
"""A00 quick start: offline, fixed draft with one approval gate."""
import json
from pathlib import Path
def main():
source = {
"id": "cedar-01",
"title": "Cedar Branch workshop notice (synthetic)",
"url": "https://cedar-library.example.invalid/notices/book-repair",
"start_time": "10:00 a.m.",
"booking_required": True,
}
start = source.get("start_time")
booking = source.get("booking_required")
if not start or not isinstance(booking, bool):
print("Missing evidence. No draft saved.")
return
requirement = "required" if booking else "not required"
# A fixed template stands in for a model. The citation URL is never fetched.
draft = {
"question": "When does the fictional Cedar Branch library workshop start, and is booking required?",
"answer": f"The fictional workshop starts at {start.rstrip('.')}. Booking is {requirement}.",
"sources": [{key: source[key] for key in ("id", "title", "url")}],
"sample_data": True,
}
payload = (json.dumps(draft, indent=2) + "\n").encode("utf-8")
print(payload.decode("utf-8"), end="", flush=True)
try:
decision = input("Type APPROVE to save this draft, or REJECT: ").strip()
except EOFError:
decision = ""
if decision != "APPROVE":
print("Approval not given. No draft saved.")
return
try:
with Path("approved-draft.json").open("xb") as output:
output.write(payload)
except FileExistsError:
print("Draft already exists. It was not overwritten.")
return
print("Saved approved-draft.json")
if __name__ == "__main__":
main()
Read the JSON preview in the terminal. Type REJECT in your first test. Check the folder for approved-draft.json. It should not exist. Run the script again and type APPROVE. The file should match the preview. Open it in a text editor and check the two facts against the source in the code.
Try one more approval in the same folder. The script opens the draft in a mode that can only create a new file. If the file already exists, the script stops and leaves it alone. Invalid input also stops the run. You can do all of this with the network off.
When you build an AI agent with more steps, test each new action on its own. Start with a rejection and check that the target stays the same.
What happened when we ran the checks
We ran the quick start on November 17, 2026, Mexico City time. In fresh local folders, a yes saved the exact text in the preview. A no, an unknown answer and the end of input each left the folder without a draft. A yes with a file already in place left that file as it was.
A larger test of the same task also stopped when a fact was missing, both reads failed or the review timed out. A fresh run could recover after a failed read with a new review. The short code shown here does not include retries or a timer. Read the four paths in the annotated architecture guide.
What to add before using a live model
If you build an AI agent with a live model, let the model suggest a step and let the app decide if the user has access to that step. Keep the preview, file path and approval tied to the same request. Ask again if any of them changes. The security checklist shows how to test the rules with sample files and real tool permissions before you use them for work.
A tool that runs on your PC can still reach an outside service. Use our Local AI guide to map where the work takes place. Start with a single action and check both a yes and a no before you let it do more.
Read also
Popular news

Good Morning AI | Anthropic slips, Claude reviews code and Tidal sets a cutoff

AI stocks slide again as Nvidia falls and Ambarella sinks 20.6%

GTA 6 on PC at 10 FPS? Inside the AI-Assisted Race to Port It

Tencent opens the AI models behind WeChat’s product search

Google’s Humanity’s First Exam Tests AI Reliability


