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

Find the Step That Went Wrong

In this lesson, you followed a hiker’s report of a wrong answer to its trace, read the trace step by step, and found the first step that went wrong. In Record a Trace per Request, you glanced at this trace and suspected retrieval. Checking every step in order confirms that suspicion.

Key Points

  • A wrong answer can look fine everywhere else. At 03:08 UTC, a hiker asked “Is the Forcella path open tomorrow?” and the assistant quoted the July 3 report calling it open, though the wardens had closed it after a rockfall. The request’s log line said "status":200, and the answer passed its checks, so nothing flagged it.
  • The run in the video uses stand-ins: the stand-in model and the stand-in retrieval from Watch a Trace Unfold, over the wardens’ reports from the simulated July season. It keeps every trace. With your sample rule, an answer nothing flagged has a trace only if the sample picked it.
  • Find the trace from the report. Search the request log for the minute the hiker gives. Here, one /ask line matched 03:08, and its request ID is the trace ID. Searching the trace file for that ID gives the request’s whole trace: four lines, retrieve, model, streamAnswer and checks.
  • Read the steps in order, and ask of each one: was its input right, and did it do the right thing with it?
  • Retrieval: its input is the hiker’s question, and it searches the wardens’ reports in data/reports.json. It returned one report, the hut 4 warden’s from July 3, saying the path was open.
  • What retrieval missed: the reports hold a newer one: on July 9, the hut 5 warden closed the route to hut 4 after rockfall. Both reports cover the stretch between hut 4 and hut 5, so that’s the Forcella path. The closure report is in data/reports.json, the file retrieval searched, so retrieval had it to find. Retrieval got the right input and returned the wrong report.
  • The tool: there’s no tool line, and a question about a path needs no hut beds, so that’s right.
  • The input as sent: the model span’s request holds the instructions, which say to answer only from the reports given, and an input with the question and the July 3 report. The closure never reached the model.
  • The output and the stop reason: the output says the latest report is from July 3 and the path is open, which is what its input said. The stop reason shows the answer wasn’t cut off.
  • The code after: the streamAnswer span records only timing, not the text. The hiker’s message quotes the answer they got, and it matches the model’s output. The checks span’s failed list was empty: the answer cited its date and gave no go/no-go verdict. But it still told the hiker the path was open when a newer report said it was closed, and that’s the wrong part.
  • Every step after retrieval did the right thing with what it got. The model answered faithfully from stale context.
  • The number: the retrieved report was 6 days older than the closure report.
  • The first step that did the wrong thing with the right input is where the answer went wrong. Here, that’s retrieval. Reading a trace only gives you a suspect, since you haven’t yet seen the answer change when the model gets the closure report. Confirming a suspect before you fix it is the habit Debugging Code You Didn’t Write builds, too.

The Fields With Your Provider

The stand-in fills 05’s neutral fields its own way: model holds its role in your config, capable, and its stop reason for a finished answer is end. With your provider, the same fields hold the model the response names and the provider’s own stop reasons:

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 Record a Trace per Request, you glanced at the Forcella trace and suspected retrieval. This time, you’ll check every step in order, to find the first one that went wrong and confirm that suspicion.

00:12 A hiker writes in. At 3:08, they asked whether the Forcella path was open tomorrow. The assistant quoted a report saying it was open. But the wardens had closed it after a rockfall.

00:26 This run uses the stand-in model and the stand-in retrieval from Watch a Trace Unfold, over the wardens’ reports from the simulated July season. It keeps every trace.

00:36 With your sample rule, an answer nothing flagged has a trace only if the sample picked it.

00:42 Start from the request log. Search it for the hiker’s minute, 3:08. One line matches, with status 200, so it wasn’t an error. Its request ID is also the trace ID.

00:54 In PowerShell, Select-String does the same. Now search the trace file for that ID. You get the request’s whole trace, four lines: retrieve, model, stream answer and checks.

01:10 Read the cards in order. For each step, ask two things: was its input right, and did it do the right thing with it? Retrieval comes first. Its input is the hiker’s question, and it searches the wardens’ reports in your project’s data folder.

01:26 It returned one report, from the hut 4 warden, dated July 3, saying the path is open. What should it have returned? Open the reports it searched. On July 9, the hut 5 warden closed the route to hut 4 after rockfall.

01:42 Both reports cover the stretch between hut 4 and hut 5, so that’s the Forcella path. That report was already in the file it searched, so retrieval had it to find, and missed it.

01:54 So retrieval got the right input and returned the wrong report. Mark it, and keep reading to check that this stale report explains the answer.

02:05 Between retrieval and the model, there’s no tool line. A question about a path needs no hut beds, so that’s right. The model card holds the request as sent.

02:17 The instructions say to answer only from the reports given. The input holds the question and one report, from July 3. The closure never reached the model.

02:29 The output says the latest report is from July 3, and the path is open. That’s what its input said. The stop reason, end, shows the answer wasn’t cut off.

02:41 The stream answer card records only timing, not the text. But the hiker’s message quotes the answer they got, and it matches the model’s output. The checks card says nothing failed, because the answer cited its date and gave no go or no-go verdict.

02:57 But it still told the hiker the path was open when a newer report said closed, and that’s the wrong part. So every step after retrieval did the right thing with what it got.

03:09 The model answered faithfully from stale context.

03:14 How stale was that report? In the Node REPL, subtract its date from the closure’s, and divide by a day in milliseconds: 6. Retrieval handed the model a report six days older than the closure.

03:29 So read a trace in order, and ask of each step: was its input right, and what did it do with it? The first step that did the wrong thing with the right input is where the answer went wrong.

03:41 Here, that’s retrieval. The model answered faithfully from a report six days stale.

03:48 But reading a trace only gives you a suspect. You haven’t yet seen the answer change when the model gets the closure report. In the next lesson, Replay a Call From Its Trace, you’ll send the recorded input again, change one step at a time, and confirm the cause.

Become a Member to join the conversation.