Skip to main content
Machine-assisted translation of the Hebrew original, awaiting the lecturer's review.

Session 3 — The first agent

Session 3 of 13PracticeDraft5 min read

Draft for the lecturer's approval.

Practice starts here. The text is awaiting approval before it counts as session guidance.

Goals​

  • Separate what is sent to the model, what comes back, and what the code carries out.
  • Run an agent loop without a key and without payment.
  • Save the work in Git so a partner can pull it.

What is sent and what comes back​

To an existing model you send instructions, the user's request, and sometimes tool results. Text comes back, or a tool request. This is using a model that has already been trained. Training changes weights from examples. In this course we do not train a model.

If there is no access to a model yet, a policy written in code is enough to learn the loop. Once you connect a model, the same skeleton stays: proposal, check, execution, result, stop.

The loop​

The file code/lab01/agent.py implements a fixed policy:

  1. If there is no calculator result yet, request a subtraction.
  2. If the result arrived, answer with a number.
  3. If the budget ran out, stop. The stop is not a numeric answer.

After pulling the repository, from inside the lab folder:

python agent.py

The expected output includes the difference 5 and the status answered. Then change the budget to 0 in the call to run and check that the status becomes stopped.

A deterministic simulation of a pre-written policy. There is no language model here, and no real email is sent.

Goal · step 1 of 9

Goal

Does QuickScreen meet both protocol requirements?

Status: running · passages: — · tool calls: 0 · 6 left

The simulation above is broader than lab 1: it also has a hostile document. It is still not a model.

Build an agent in VS Code​

The same loop, with a real model. The video "Build an AI agent in VS Code" walks the whole way: a free model running on your own computer, developing the agent, an evaluation that measures and improves it, and sharing its tools over MCP. It is on the videos page, with a full transcript. The code from the video is in code/vscode-agent/.

Git, briefly​

Create a private repository on GitHub and invite your partner.

git status
git add agent.py
git commit -m "Add the first deterministic agent loop"
git push

A partner's small change goes through a branch and a Pull Request, not straight into the main branch. A .gitignore file keeps out the virtual environment, keys, and model weights. A key does not go into the code even if the repository is private.

Exercise​

Change the calculator action from subtraction to division by zero. Write down what the status is, how many times the tool ran, and whether you may report that the task was completed.

Check your understanding​

The loop reached the end of its budget without a tool result. What do you return?

Pick an answer to see the explanation. There is no grade here.

Summary​

Found a mistake on this page? Email the lecturer

Accessibility settings

These settings change how this site looks on this device only. They are saved in this browser.

Text

Colour

Light and dark mode are in the top bar, next to search.

Reading and navigation