Answer the Question That Needs Two Documents
How long is the warranty on what Dana bought? One note says Dana bought the K-70; another gives the K-70 a three-year warranty. The question never mentions the K-70, so one search finds the Dana note and a look-alike warranty note for the wrong model, and the starter code says five years. This is a multi-hop question: the second search's query does not exist until the first search has been read.
retrieve(query) (provided) returns the two notes nearest a query, each {"id", "text"}, by a real embedding model. Two notes per search is all you get.
Implement answer(question), returning {"answer": ..., "sources": [...]}:
- Retrieve for the question.
- Show the model the question and what was found, and ask what is still missing: it replies with a search query for the missing fact, or the word
DONEif the notes already answer the question. - If there is a follow-up query, retrieve for it.
- Ask the model to answer from every note retrieved, in one short sentence.
"sources" is the ids of every note retrieved, each once, in the order first seen. "answer" is the model's answer.
Budget: at most two searches and three model calls per question. Stopping after one search when it is enough saves a call, but the tests do not insist on it; when in doubt, search.
The tests check properties: the right fact in the answer, both notes it rests on in the sources, and the budget kept.