Skip to main content

Quiz: API Basics

Why This Matters

Module 2 is the base for everything that follows. This quiz checks the decisions, not the syntax. Answer before you open each answer; the questions are written by Learn Automated Testing, not taken from the real exam.

Quiz

1. TestPilot’s answers drive an automatic message to the developer who broke the build. Which setup is the safest?

  • A. Ask for JSON in the prompt and parse it with JSON.parse
  • B. Ask the model to double-check its own JSON before answering
  • C. Use the highest effort setting
  • D. Send a schema as the output format and validate the result in code before acting
Show answer
D. The output format makes the right shape very likely; validating in code makes it certain before anything acts on it. A can break on any malformed answer, B and C still rely on the model.
Quiz

2. The nightly triage job crashes when the API returns an overloaded error for one of 40 failures. What is the best fix?

  • A. Retry that request with backoff, and if it still fails, report it as untriaged while keeping the other 39 results
  • B. Retry the whole job from the start
  • C. Switch to a smaller model
  • D. Run the job less often
Show answer
A. Transient errors deserve a retry; a persistent one should cost you one result, not the whole run, and the report should say so honestly. B repeats 39 successful calls, C and D do not address the failure.
Quiz

3. Your system prompt and category definitions are 3,000 tokens and identical on every call. What reduces cost without changing the output?

  • A. Shorten the definitions
  • B. Lower max_tokens
  • C. Prompt caching for the unchanging part at the start of the request
  • D. Move the definitions into the user message
Show answer
C. Caching makes repeated identical content much cheaper to read and does not change what the model sees. A may change the output, B limits the answer rather than the input, D changes nothing about cost.
Quiz

4. In npm run ask, the third question gets an answer that ignores the first triage. What is the most likely cause?

  • A. The model forgot the conversation after two turns
  • B. max_tokens is too high
  • C. The system prompt is too long
  • D. Your code did not send the earlier user and assistant messages
Show answer
D. The model never remembers anything between requests; it only sees what you send. If the earlier turns are missing from the array, it cannot use them.
Quiz

5. TestPilot sometimes returns “flaky” for a failure whose history is all “passed”. Which change is the most reliable?

  • A. Add “never say flaky without failure history” to the system prompt in capitals
  • B. Reject “flaky” in code when the failure rate is 0, and retry once with that feedback
  • C. Lower the temperature
  • D. Add five examples of flaky tests to the prompt
Show answer
B. The rule has a real cost when broken (a hidden product bug), so it belongs in code. The retry with feedback gives the model a chance to correct itself. A and D only make the mistake less likely, and C is not available on current models, which accept only the default sampling settings.