Curriculum

Curriculum

Tell the Agent How to Handle Invalid Inputs

Scenario

Compare three task briefs asking an agent to implement canBook(freeSeats).

Selected choicePick a choice below
Result—

Try it yourself

Choose each brief to see whether the agent must guess on freeSeats = -1.

Reveal the explanation
  1. "Implement canBook(freeSeats) returning true when seats are free."

    Underspecified! Agent might return false on -1 or coerce "2" silently.

  2. "Implement canBook and handle bad inputs gracefully."

    Still ambiguous: does "gracefully" mean return false, null, or throw an error?

  3. "Reject non-integers or freeSeats < 0 with INVALID_FREE_SEATS; return freeSeats > 0 otherwise."

    Checkable! Both you and the agent agree on every invalid case before coding.

Always include one invalid-input sentence and one concrete invalid test case in your agent brief.

Review first

Your turn

Add an explicit invalid-input sentence to: "Write scoreQuiz(answerKey, studentAnswers) returning total matching answers."

Common mistake Writing "handle unequal lists safely" without naming the expected error code.

Check your work

If answerKey.length != studentAnswers.length, raise/return INVALID_LENGTH.

Quick check

Why is "handle bad inputs gracefully" weak in an agent task brief?
Show the answer and reasoning

Correct answer It leaves the agent guessing between returning false, returning 0, or throwing an error

Naming the exact invalid condition and error code removes all guesswork.