Price: $0.05537 3.1839%
Market Cap: $8.69B 0.417%
Volume (24h): 481.53M 0%
Dominance: 0.417%
Price: $0.05537 3.1839%
Market Cap: $8.69B 0.417%
Volume (24h): 481.53M 0%
Dominance: 0.417% 0.417%
  • Price: $0.05537 3.1839%
  • Market Cap: 8.69B 0.417%
  • Volume (24h): 481.53M 0%
  • Dominance: 0.417% 0.417%
  • Price: $0.05537 3.1839%
Home > 视频 > Build Your First AI Agent in Python: Tools, Loop, Stop Rules

Build Your First AI Agent in Python: Tools, Loop, Stop Rules

Release: 2026/11/13 13:42 Reading: 0

Original author:AI Made Clear

Original source:https://www.youtube.com/embed/viJZmtGWmXw

Part 16 of the free AI Engineer course: your first AI agent. An agent chooses between several tools, keeps going until the job is done, and knows when to stop. You see a multi-step run, five stop rules, why the message history becomes a cost problem, and how to test an agent. The "model" in the demos is a mock I wrote by hand, not a real AI, and no real API call is made. In this video: - Workflow or agent? Who decides the next step - The message list is the agent's memory - A real multi-step run and its trace (list orders, then calculate) - How the description steers the choice between tools - Five ways a run ends: done, max turns, max calls, token budget, repeat - The history problem: every turn re-sends everything, and trimming old results - Testing the path, not only the answer (20 tests) - 4 exercises and a quiz CHAPTERS 0:00 Start here: your first AI agent 1:09 What an agent is 2:55 The memory of an agent 3:44 A multi-step run 4:55 Choosing between tools 6:13 Stop rules 8:07 The history problem 9:45 Testing an agent 11:25 Put it together 12:56 Your turn 14:29 Check yourself COURSE CODE (Parts 1 to 16) Part 16 files: agent.py, tools.py, schema.py, mock_agent_model.py, demo16.py, test_agent.py. No extra packages (Python 3.11+). EXERCISES 1. Add a fifth read-only tool with a four sentence description and an input schema, then write a goal that needs it and a test for the path. 2. Add a new stop rule of your own (for example a time limit), and a test that proves it ends the run. 3. Run the trim demo with keep_last set to 2 and compare the estimated tokens and the answer. 4. Stretch: write the real model function (key in .env, never in code), run the same goals, compare its traces with my mock, and keep small limits. HONEST NOTES - I had no model key and my workspace cannot reach public APIs, so no real model was used in this part. The mock model is hand-written rules, not an AI; its replies have the same shape as the real API, so the loop, stop rules, history trimming and tests are real code. The terminal screens are real runs of my own code (Linux, Python 3.13, 5 Nov 2026) with made-up orders. Token numbers are a rough estimate (about 4 characters per token), not a real tokenizer. Windows not tested. - The ideas (workflow vs agent, start with the simplest solution, stopping conditions, human checkpoints, careful tool design, testing in a sandbox) come from Anthropic's article "Building effective agents" (published 19 Dec 2024) and Tool use pages, read 5 Nov 2026; they can change. No prices quoted. SOURCES (read 5 Nov 2026) Anthropic, Building effective agents: https://www.anthropic.com/engineering/building-effective-agents Anthropic, Tool use overview: https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview Subscribe to AI Made Clear for plain English AI tips. Disclosure: the voice is AI-generated. Screens labelled real run are real terminal output from my own code with a mock model (not a real AI); other screens are illustrations. Anthropic, Python and other names belong to their owners. This channel is not affiliated with any company named. Business inquiries: rabbihossain01941@gmail.com #AIEngineer #AIAgents #Python

Selected Topics

  • Dogecoin whale activity
    Dogecoin whale activity
    Get the latest insights into Dogecoin whale activities with our comprehensive analysis. Discover trends, patterns, and the impact of these whales on the Dogecoin market. Stay informed with our expert analysis and stay ahead in your cryptocurrency journey.
  • Dogecoin Mining
    Dogecoin Mining
    Dogecoin mining is the process of adding new blocks of transactions to the Dogecoin blockchain. Miners are rewarded with new Dogecoin for their work. This topic provides articles related to Dogecoin mining, including how to mine Dogecoin, the best mining hardware and software, and the profitability of Dogecoin mining.
  • Spacex Starship Launch
    Spacex Starship Launch
    This topic provides articles related to SpaceX Starship launches, including launch dates, mission details, and launch status. Stay up to date on the latest SpaceX Starship launches with this informative and comprehensive resource.
  • King of Memes: Dogecoin
    King of Memes: Dogecoin
    This topic provides articles related to the most popular memes, including "The King of Memes: Dogecoin." Memecoin has become a dominant player in the crypto space. These digital assets are popular for a variety of reasons. They drive the most innovative aspects of blockchain.