Assignment 3#
Due: Wednesday Sep 16th at 11:59 pm ET
The goal of this assignment is to practice agentic coding with GitHub Copilot in Agent mode, applying the ideas from the Working with GenAI Tools lecture. You will use an AI coding agent to rebuild the distance tool you wrote manually in Assignment 2, then push it further than you did before — with a test suite, input validation, and a new route-distance feature — all while keeping the agent on rails and taking full responsibility for the code it produces. Read the whole assignment, specifically Part 5, before starting to implement these as you have to capture your reflections.
A note on responsibility
An agent writes code, but you own everything you commit. Read every change the agent proposes before you accept it, and never commit code you do not understand. Part of your grade is evidence that you reviewed and understood the agent’s work, not just that it runs.
What you are practicing
Agentic coding — driving GitHub Copilot in Agent mode to accomplish a goal in a loop.
Context engineering — writing an
AGENTS.mdthat constrains and guides the agent.Quality assurance — a test suite the agent’s code must pass (
pixi run test).Judgment & reflection — comparing agent-written code to your own and owning the result.
All of your work lives in a new directory named assignment-3/ inside your geog313-assignments repository. Do not copy any code or files from assignment-2/. You are rebuilding from an empty folder — the point is to see what an agent produces from scratch and how it compares to what you wrote yourself.
Note
As in Assignment 2, stage your files explicitly by name and do not use git add . Run git status before every commit, commit in small focused steps, and push as you go. We expect a commit history that shows the tool being built up incrementally with the agent — not one giant commit.
Part 1: Set Up the Project and Your Agent (10 pts)#
Make sure GitHub Copilot is enabled in VS Code. As a student you have free access through the GitHub Education benefits you set up earlier in the course; if you have not activated Copilot yet, do so now.
From the root of your
geog313-assignmentsrepository, create a fresh, empty Pixi project.Edit
pixi.tomlso theplatformsline supports the operating systems used in this class:platforms = ["osx-arm64", "osx-64", "linux-64"]
Open the Copilot Chat panel in VS Code and switch it to Agent mode using the mode dropdown.
Make your first commit with just the scaffolding (
pixi.toml,.gitignore).
Part 2: Write Your AGENTS.md (20 pts)#
Before you ask the agent to write a single line of code, you will write the instructions that tell it how to work in this repository. This is context engineering: a clear AGENTS.md keeps the agent consistent, prevents it from wandering off (adding stray dependencies, restructuring your files, changing your tasks), and uses fewer tokens to get to a good result.
Create a file named AGENTS.md at the root of assignment-3/. It should include, in your own words:
What this project is — a short description of the distance tool.
Project layout — which files exist and what each is for; an instruction not to create extra files or directories. Naming the exact files and forbidding new ones keeps the agent’s output small and diffable, which is the whole point of being able to own what it produces.
Environment and tooling — this project uses
pixionly; the agent must never suggestpip,conda, orvenv; the only third-party dependency allowed istabulate(plus a testing tool); the agent must not edit the[tasks]section without being asked.Domain constraints — use the haversine formula on a spherical Earth with radius 6371 km; latitude must be in [−90, 90]; longitude should be normalized into [−180, 180]; report distances in kilometers and miles.
Code structure rules — the core distance function stays a pure function (numbers in, number out) so tests can call it directly; anything that reads from the terminal lives inside
if __name__ == "__main__":.Definition of done — for example:
pixi run testpasses andpixi run distancesprints the table.
Commit AGENTS.md. You will refer the agent to it as you work.
Tip
A good AGENTS.md is specific and short. If you find the agent repeatedly doing something you do not want (installing a package, renaming things, adding files), that is a signal to tighten your AGENTS.md rather than to keep correcting it by hand each turn.
Part 3: Rebuild the Assignment 2 Tool — With the Agent This Time (25 pts)#
Using Copilot in Agent mode, and referring it to your AGENTS.md, have the agent build the same tool you wrote by hand in Assignment 2. Work in small steps, reviewing and committing after each accepted change. The finished tool must:
Provide a
haversine(lat1, lon1, lat2, lon2)function that returns the great-circle distance in kilometers (Earth radius 6371 km).Hold a list of at least five locations (name, latitude, longitude).
Print a pairwise distance table between those locations using
tabulate, in both kilometers and miles.Include a nearest-neighbor helper that reports, for a given location, which other location is closest and how far.
Be runnable with a
distancestask, sopixi run distancesprints the table.
Commit all new files after this part.
Own the code
For every change the agent proposes: read the diff, make sure you understand it, and only then accept it. If the agent adds a dependency, renames a function, or creates a file that your AGENTS.md forbids, reject it and steer it back. Commit each accepted step with a clear message and push.
Part 4: Go Beyond Assignment 2 (30 pts)#
Now use the agent to add three things your hand-written Assignment 2 tool did not have. Continue to work in small, reviewed, committed steps.
4.1 Input validation and robustness#
Have the agent make the tool robust to bad input:
Reject latitudes outside [−90, 90] with a clear error.
Accept arbitrary longitudes by normalizing any value into [−180, 180] (so, for example, 200° becomes −160°).
4.2 Total-route distance#
Add a function that computes the total great-circle distance of traveling through your list of locations in order (the sum of the consecutive leg distances), and report it when the tool runs.
4.3 A test suite#
Add a testing tool to the project (for example
pytest) and define atesttask so the suite runs withpixi run test.Have the agent write tests for your
haversinefunction against known values — for example, one degree of longitude at the equator, and the distance between two cities whose separation you can look up — and tests for the validation rules in 4.1.Verify the tests are meaningful. Agents sometimes write tests that always pass or that simply echo the implementation. Read each test and make sure it would actually fail if the code were wrong. Iterate with the agent until
pixi run testpasses and the tests are honest.
Commit each addition separately and push. Make sure pixi run distances and pixi run test both work from a clean state.
Part 5: Reflection (15 pts)#
Write a file named reflection.md in assignment-3/. Write it yourself, without AI assistance — this reflection is about your own thinking. In roughly 400–600 words, address:
How did the agent’s code differ from the code you wrote by hand in Assignment 2? Consider structure, naming, the approach to the haversine math, error handling, and style. What did the agent do better, and what did you prefer about your own version?
Where did the agent go wrong — a bug, a misunderstanding, a violation of your
AGENTS.md— and how did you catch and correct it?How did writing
AGENTS.mdchange the agent’s behavior? Did tightening it help?What will you do differently the next time you use an AI coding agent?
Deliverables#
Everything is committed to your geog313-assignments repository, in assignment-3/:
pixi.toml,pixi.lock, and.gitignore.Your tool code (for example
distance.py) implementing the Part 3 functionality plus the Part 4 additions.A test file (for example
test_distance.py);pixi run testpasses.AGENTS.md.reflection.md, written without AI.A commit history showing incremental, reviewed, agent-assisted development.
pixi run distances prints the distance table and total route distance; pixi run test passes.