agentic_ai_basics

human_in_the_loop

Human-in-the-Loop (HITL) — a human approves or corrects an agent’s actions at key checkpoints, before they execute.

human_in_the_loop.py

An email assistant that can freely search a mock inbox, but must get human approval before actually sending anything — the human can approve, reject with feedback, or edit the message first. Type exit to quit.

Concepts covered

Run

From the repo root:

pip install -r requirements.txt
export ANTHROPIC_API_KEY=your-key-here
python3 Execution_Loops/human_in_the_loop/human_in_the_loop.py

Try:

You: Reply to Sara agreeing to move the budget review to Tuesday.

  >>> APPROVAL NEEDED: send_email({'to': 'sara@example.com', 'subject': 'Re: Q3 budget review', 'body': '...'})
      [a]pprove / [r]eject / [e]dit? a
  [tool] send_email({...})
  [result] Email sent to sara@example.com — subject: 'Re: Q3 budget review'

Configuration

See also