In this video, you traced a wrong answer from the rules desk back to a chunk the search never sent, and fixed it in the chunker rather than the prompt.
Key Points
- A wrong answer with a valid citation. Table 3 asked whether a runner who’s already on the summit path can still take the baton in Summit Relay. The desk said no and cited Summit Relay, page 4. Your wording will differ, and so could the answer, but every run here said the same no. Page 4 ends partway through a sentence, “A runner who is already on the summit path can’t take the baton,” and page 5 finishes it: “unless the runner is on space 12, the wide ledge halfway up.” So the answer is yes. The citation passed the desk’s check, because a valid citation only proves the chunk was sent, not that it was the right one.
- Check retrieval first. It’s tempting to reword the prompt. Instead, check what was retrieved before you touch the prompt or the model.
- Log what was sent.
logChunks()prints each chunk the desk sent,result.chunks, with its rank, score, game, page and heading, the same printout you used to search the rulebooks. The script prints the input tokens too, so you can see what a change costs. Four chunks went to the model, from pages 4, 2, 3 and 3, each score including the game bonus. There was no page 5. The Hand-offs chunk stops mid-sentence, at “can’t take the baton,” and the model answered as if that were the whole rule. The problem is retrieval, not the prompt. - Why page 5 wasn’t sent. The chunker never let a chunk cross a page marker, so the start of page 5 became a chunk of its own, labeled with the page alone. It never mentions hand-offs or the baton.
- Why a bigger k isn’t the fix. With k at 8, the page 5 chunk came in eighth and the desk answered right. But it barely made it, so different wording could leave it out. Every question would pay for eight chunks: 964 input tokens here instead of 609, about half as much again (about 0.27 cents instead of 0.18 for this question). And the rule would still be split.
- Keep the sentence together. In
chunks.js,MID_SENTENCEmatches a line that starts with a lowercase letter. It’s a rough test that fits these rulebooks, where other pages open with a heading or a capital. A sentence that breaks before a name or a number would still split, so other documents need their own check. By the timesplitSections()reads page 5’s first line, the page marker has already opened page 5’s empty section, so the section before issections.at(-2). When that first line matches, it finishes the sentence of the section before, sosplitSections()pushes it there and sets that section’sendPageto 5. InchunkRulebook(), a section without a carried line ends on its own page (endPage = page). A carried line lands in the section’s last chunk, so only that chunk getsendPage, not a long section’s earlier chunks. Rebuilding the index embedded only the two changed chunks, and two stray chunks like page 5’s were gone: 88 chunks, down from 90. - Pages 4 to 5.
search()copiesendPageinto each result, andsourceLabel()indesk.jsthen gives a page range when a chunk ends on a later page. The same four chunks came back, but the top one now held the exception too. The desk said yes, on space 12, and cited Summit Relay, pages 4-5, so a player who checks finds both halves. That took 625 input tokens, close to the 609 before. - Rerun every question. A chunker change touches every rulebook, so rerun
check-all.js. Its lines only count citations: question 5’s line looks as it did, though its answer flipped. So print each reply too, and read the answers against the rulebooks. All nine answers still match the rulebooks, and the other three still decline. In the counts, question 7 changed because of the fix: Glasshouse’s frost rule had the same split, so its answer now cites one chunk, pages 3 to 4, not two. Question 12’s count varies from run to run.
The rule:
- Log the chunks that were sent (
logChunks(result.chunks)). - Right chunk missing: fix retrieval (here, the chunker).
- Right chunk sent, answer still wrong: look at the prompt or the model.