AI Agent Loop Starter Kit for Claude

AI Agent Loop Starter Kit for Claude showing Python files and a symmetric architecture with memory, guardrails, tools and verified output.
Free digital product — no payment required
Request your copy with your name and email
Receive the download link directly in your inbox
No credit card or billing address needed
No checkout or store account to create
Save your copy for later
Description

Open the code. Follow the tools. Check the result.

Build a practical understanding of an AI agent by running a small, inspectable example. This free ZIP contains editable Python source, task instructions, fictional contacts and a price list. The example prepares an email draft with the correct recipient and a real CSV attachment, then checks the saved file.

The code makes the boundary between the model and the surrounding application visible. A model can request an action; the runtime validates and executes an allowed tool. Its result returns to the next model call, which can continue, ask for information or finish.

Try it offline

Start with the scripted sample. No API key, model account or network connection is needed to inspect the loop and the files it creates.

Connect your Claude account

Use live mode when you want Claude to choose the actions. Supply your own Anthropic API key and an accessible model ID; API usage is billed separately by the provider.

Understand the complete agent loop

The architecture brings together the request, relevant context, memory, model decisions, tools and returned evidence. Permissions and limits belong around that loop. A clear stopping condition helps distinguish a completed task from a reassuring sentence.

Illustrated agent architecture with centered memory, guardrails, context, model, tools and a goal decision.
Architecture illustration. The supplied starter runs locally from a terminal. Cost, latency and eval monitoring in the wider map are extension ideas.

Follow one task from request to draft

“Prepare a short email to Sarah Lee with the current price list. Save a draft for review.”

1. Verify the contact

The contact tool reads the local sample list. A full name identifies the recipient; an ambiguous match returns an error instead of silently selecting someone.

2. Retrieve the current file

The price-list tool reads the CSV and records its fingerprint. The source is checked again before saving, so a changed attachment requires a fresh lookup.

3. Create a checked draft

The draft tool saves an .eml file with the actual CSV attached. It opens the saved message data again to verify the recipient, filename and attachment bytes.

The included find_contact, read_price_list and save_email_draft tools, with an illustrated returned result.
The three local tools in the ZIP. This view illustrates dispatch and returned evidence; it is not a recording of a live Claude API session.

See the file the included example produces

The offline demo creates a real mail file in the output folder. The preview below is built from that generated .eml and its attached CSV. The sample uses a fictional contact and illustrative service prices. Inspect the message and attachment before adapting the source data.

Actual offline-demo draft to the fictional sarah.lee@example.com, with the sample CSV price list attached.
Preview generated from the included scripted demo output. The recipient and attachment were verified against the local source files.

What the ZIP contains

  • agent.py – the Claude adapter, three local tools, execution loop, source checks, memory and action logging.
  • AGENT_INSTRUCTIONS.md – editable task instructions, permitted behavior and completion criteria.
  • sample_contacts.json and sample_price_list.csv – fictional input records and the actual attachment used by the example.
  • test_agent.py – 16 offline tests covering ambiguous names, changed or missing sources, invalid tools, model errors, truncation and limits.
  • README.md, BUILD_IN_CLAUDE.md and VALIDATION.md – setup instructions, a brief for extending the project in Claude Code and the scope of the checks performed.
  • PACKAGE_MANIFEST.json – file fingerprints for checking the contents of the download.

Get started in four steps

  1. Extract the complete ZIP into one folder. Use Python 3.10 or newer.
  2. Open a terminal in the extracted folder. The starter uses the standard library, so there are no extra Python packages to install.
  3. Run python agent.py --demo to generate the scripted sample.
  4. Open output/result.json and the draft named in its result. Review the recipient, message and attachment.

For the Claude-powered mode, configure ANTHROPIC_API_KEY and ANTHROPIC_MODEL in your environment, then run python agent.py --live. The key stays outside the downloadable source files. Your live task and relevant tool results are sent to Anthropic.

Keep context, memory and evidence separate

Memory for the next run

After a successful run, a small memory file records the last verified draft, recipient and attachment fingerprint. A later run still looks up the current sources again.

An action log you can inspect

The JSONL log records model calls, requested tools, returned results, errors and the final status. This makes it easier to find where a run succeeded or stopped.

Default controls allow up to eight model calls and twelve tool calls, with a run-time budget checked between operations. A missing source, a limit or an API error can stop the run. A plain-text claim of success does not replace a verified draft file.

Common questions

Can I try it without an API key?

Yes. The offline demo and included tests run locally without network calls or API credits. That mode uses fixed responses to demonstrate the tool loop. Live Claude decisions require your own API access.

Does it send the email?

The result is a local draft for human review. You review the message and attachment, choose an email account and send it separately. The supplied tool set ends at creating and verifying the draft.

Can I change the data and instructions?

Yes. The Python source, Markdown instructions, contact records and CSV are editable. Use the fictional sample to understand the formats before substituting real data. Review model-written content before use.

What has been checked?

The package passes 16 offline tests and an extracted-ZIP demo run, including verification of the generated attachment. Model responses and API-message structure are tested with offline fixtures. Configure and verify a real API run with your own account before relying on live output.

A downloadable educational starter with source code and fictional sample data. It runs on your computer; the ZIP is not a hosted automation service or a course subscription.