Decide how an onboarding agent answers from docs

Agent buildEasy10 minOpenAI and Anthropic style

Your task

New engineers ask the same questions for months because the answers are buried in internal docs, many of them stale. An agent answers from those docs, and has to know when not to.

Write decide_doc_answer_action(topic, doc_ages_days, sources_conflict): the rule your agent follows for each question.

  • topic (str): the question as asked.
  • doc_ages_days (list of int): the age in days of each doc passage retrieved for it. It may be empty.
  • sources_conflict (bool): the retrieved passages disagree.

It returns one of the values in the rules below. Apply them in order. The first one that matches decides:

  1. The topic, lowercased, contains credential, password, secret, security or access anywhere: "route_to_human". This comes first, even when nothing was retrieved.
  2. No passages: "say_unknown".
  3. Find the freshest passage, the one with the smallest age. A negative age is a bad timestamp: count it as 0. If the freshest is over 730 days old: "say_unknown".
  4. sources_conflict: "answer_with_conflict_note".
  5. The freshest is over 365 days old: "answer_with_stale_warning".
  6. Otherwise: "answer".

Examples

decide_doc_answer_action(topic: str, doc_ages_days: list[int], sources_conflict: bool) -> str
Example 1
Inputdecide_doc_answer_action("how do i deploy the web app", [12, 400], False)
Output"answer"
Example 2
Inputdecide_doc_answer_action("where are the production credentials stored", [3], False)
Output"route_to_human"
Example 3
Inputdecide_doc_answer_action("what is our code review policy", [500, 900], False)
Output"answer_with_stale_warning"