Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Watch an Agent Check Itself

In this video, you watched an example session of task 1 for the escape-room builder, written for the video rather than recorded. In task 1, the agent returns the ids of the puzzles no path reaches, and its done-when ends in a new test on both sample rooms with npm test passing. Then you watched the same task in a session with no check to run. Your own sessions will differ, but their shape should be the same.

Key points:

  • The agent added a test with the task’s two examples: an empty list for The Lighthouse Keeper’s Study, and the strongbox and the trapdoor for The Smuggler’s Cellar.
  • Its first version looked for needs that no puzzle in the room unlocks. That caught the iron strongbox, which needs the iron key. The code read well, and nothing in it looked wrong.
  • The agent ran the check. One test passed and one failed, and the failure showed what the test expected and what the function returned: the trapdoor was missing. The trapdoor needs a code from inside the strongbox, and the strongbox unlocks that code, so the first version never reported the trapdoor. But nothing opens the strongbox, so the trapdoor can’t be reached.
  • The agent read that failure and edited the function. The new version walks the room the way the brief defines finishing it: start with nothing, solve every puzzle whose needs are found, and collect what each one unlocks. The puzzles left over are the unreachable ones. It ran the check again, both tests passed, and only then did it report that it was done.
  • The agent changed the code, ran the check, read the failure, fixed the code, and ran the check again. That cycle is a feedback loop, and a check the agent can run lets it go round until the check passes.
  • In this example it went round once, because one fix caught the puzzle stuck behind the strongbox. On a bigger task it can go round many times. The check’s output tells the agent what to fix. It can also go round without getting closer, or stop with the check still failing. Then you step in and tell it what you know, or sharpen the task.
  • In the second session, the done-when named no command and the agent had no permission to run one. It wrote the same test and the same first version, and its model predicted what the code would do. Its report repeated the examples from the task.
  • Some reports say the tests weren’t run, and some don’t. This one didn’t, and it read word for word like the first session’s. But run the test on that code, and one test fails with the trapdoor missing. Nothing in the session showed the agent that failure.

With a check it can run, an agent can see what fails and work on it until the check passes. Without one, it can only predict, and its report can sound the same either way. Telling the two apart from a report comes later, in Read Done Reports as Claims.

Here’s the new test the example session added to test/check-room.test.js. The code below is a small example made for the video, and your agent’s code will differ:

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

00:00 In Write a Finishable Task, you gave your agent task 1: return the ids of the puzzles no path reaches. Its done-when ended in a check: a new test on both sample rooms, with npm test passing.

00:15 Your agent can also run that check while it works. When you ran task 1, your agent may have asked before running npm test, so you’ve seen part of this already.

00:26 In this video, you’ll watch a session use the check, step by step. Then you’ll see the same task with no check to run.

00:35 Here’s how that session might go, in an example written for this video. Your own session will differ, but its shape should be the same. The agent reads the brief and the checker.

00:47 It adds a test with your task’s two examples: an empty list for the Lighthouse Keeper’s Study, and the strongbox and the trapdoor for The Smuggler’s Cellar.

00:57 Then it writes the function. This first version looks for needs that no puzzle in the room unlocks. That catches the iron strongbox, which needs the iron key.

01:09 The code reads well. Nothing in it looks wrong.

01:15 Now the agent runs the check from your done-when. One test passes, and one fails.

01:22 The failure says what the test expected and what the function returned. The strongbox is there. The trapdoor is missing. The trapdoor needs a code from inside the strongbox.

01:35 The strongbox unlocks that code, so the first version never reports the trapdoor. But nothing opens the strongbox, so the trapdoor can’t be reached. The next lesson shows you how to read this output.

01:49 For now, you only need the trapdoor line, which the test expected and the function didn’t return.

01:56 The agent reads that line, and edits the function again. This time, it walks the room the way your brief defines finishing it. It starts with nothing, solves every puzzle whose needs are found, and collects what each one unlocks.

02:11 The puzzles left over are the unreachable ones.

02:15 Then it runs the check again. Both tests pass, and none fail. Only then does it report that it’s done.

02:26 The agent changed the code, ran the check, read the failure and fixed the code, then ran it again. That’s a feedback loop. A check it can run lets the agent go round it until the check passes.

02:40 Here, it went round once, because one fix caught the puzzle stuck behind the strongbox. On a bigger task, it can go round many times. The check’s output tells it what to fix.

02:52 It can also go round without getting closer, or stop with the check still failing. Then you step in and tell it what you know, or sharpen the task.

03:03 Now the same task, in a session where the agent can’t run anything. Its done-when names no command, and the agent has no permission to run one. It writes the same test and the same first version.

03:17 Then, instead of a run, its model predicts what the code will do. Its report repeats the examples from your task: the strongbox and the trapdoor for The Smuggler’s Cellar.

03:29 Some reports say the tests weren’t run, and some don’t. This one doesn’t. Side by side, the two reports read word for word the same. But run the test on this code, and one test fails, with the trapdoor missing.

03:45 Nothing in this session showed the agent that failure.

03:50 So a check it can run lets an agent work in a loop until the check passes. One that can’t run a check can only predict, and its report can sound the same either way.

04:02 Telling the two apart from a report comes later, in Read Done Reports as Claims.

04:08 Next, in Give Your Agent Checks to Run, you’ll put your project’s test commands in its instruction file, and let your agent run them without asking each time.

Become a Member to join the conversation.