{"id":"08-state","number":8,"slug":"designing-state","title":"State: give it what it needs","short":"State","module":"Asking good questions","summary":"The state is everything the model sees besides your questions. Here is how to shape it (named fields, paths the questions point at, the record next to the policy), what we measured when we buried the one thing that mattered, and the limits on length, language and context you should design around.","voice":"Jessica","scenes":[{"template":"title","chapter":"Intro","narration":"Every request has two halves: your questions, and the state they're asked about. Most failures we'll see in this course start on the state side. So let's shape it well.","params":{"kicker":"Lesson 8","module":"Module 2 · Asking good questions","title":"State: give it *what it needs*","subtitle":"Named fields, pointed questions, nothing extra.","cast":["curly","snap"]},"start":0.5,"dur":11.962,"words":[{"text":"Every","s":0.8,"e":1.12},{"text":"request","s":1.36,"e":1.6},{"text":"has","s":1.68,"e":1.92},{"text":"two","s":2,"e":2.16},{"text":"halves:","s":2.24,"e":3.04},{"text":"your","s":3.12,"e":3.2},{"text":"questions,","s":3.28,"e":4.16},{"text":"and","s":4.2,"e":4.24},{"text":"the","s":4.32,"e":4.4},{"text":"state","s":4.48,"e":4.72},{"text":"they're","s":4.76,"e":4.88},{"text":"asked","s":4.96,"e":5.2},{"text":"about.","s":5.28,"e":6.16},{"text":"Most","s":6.24,"e":6.48},{"text":"failures","s":6.56,"e":6.96},{"text":"we'll","s":7,"e":7.2},{"text":"see","s":7.24,"e":7.28},{"text":"in","s":7.36,"e":7.44},{"text":"this","s":7.52,"e":7.6},{"text":"course","s":7.68,"e":8.08},{"text":"start","s":8.16,"e":8.4},{"text":"on","s":8.48,"e":8.56},{"text":"the","s":8.6,"e":8.64},{"text":"state","s":8.8,"e":9.12},{"text":"side.","s":9.32,"e":9.92},{"text":"So","s":10.12,"e":10.32},{"text":"let's","s":10.4,"e":10.64},{"text":"shape","s":10.76,"e":10.88},{"text":"it","s":10.96,"e":11.04},{"text":"well.","s":11.2,"e":11.6}]},{"template":"statement","chapter":"What state is","narration":"The TypeSafe docs have a good image for it. Think of the state as the material you'd present to a panel of experts before asking them to make a judgment. The customer's message. Their order. The policy that applies. Everything an expert would need, and nothing they wouldn't.","params":{"eyebrow":"TypeSafe docs","text":"Think of state as the material you'd hand *a panel of experts* before asking them to judge.","art":"users","tone":"s2","punch":"panel of experts"},"start":12.462,"dur":17.459,"words":[{"text":"The","s":12.762,"e":12.922},{"text":"TypeSafe","s":13.042,"e":13.482},{"text":"docs","s":13.562,"e":13.802},{"text":"have","s":13.882,"e":13.962},{"text":"a","s":14.042,"e":14.122},{"text":"good","s":14.202,"e":14.282},{"text":"image","s":14.362,"e":14.602},{"text":"for","s":14.682,"e":14.842},{"text":"it.","s":14.962,"e":15.322},{"text":"Think","s":15.562,"e":15.722},{"text":"of","s":15.762,"e":15.802},{"text":"the","s":15.882,"e":15.962},{"text":"state","s":16.042,"e":16.442},{"text":"as","s":16.522,"e":16.602},{"text":"the","s":16.682,"e":16.722},{"text":"material","s":16.762,"e":17.242},{"text":"you'd","s":17.322,"e":17.482},{"text":"present","s":17.682,"e":17.882},{"text":"to","s":17.922,"e":17.962},{"text":"a","s":18.042,"e":18.122},{"text":"panel","s":18.202,"e":18.442},{"text":"of","s":18.522,"e":18.602},{"text":"experts","s":18.682,"e":19.162},{"text":"before","s":19.242,"e":19.642},{"text":"asking","s":19.802,"e":20.042},{"text":"them","s":20.122,"e":20.202},{"text":"to","s":20.282,"e":20.362},{"text":"make","s":20.442,"e":20.522},{"text":"a","s":20.575,"e":20.629},{"text":"judgment.","s":20.682,"e":21.242},{"text":"The","s":21.722,"e":21.762},{"text":"customer's","s":21.802,"e":22.282},{"text":"message.","s":22.362,"e":23.082},{"text":"Their","s":23.242,"e":23.402},{"text":"order.","s":23.482,"e":23.882},{"text":"The","s":24.202,"e":24.282},{"text":"policy","s":24.362,"e":24.762},{"text":"that","s":24.802,"e":24.842},{"text":"applies.","s":24.922,"e":25.762},{"text":"Everything","s":26.042,"e":26.442},{"text":"an","s":26.482,"e":26.522},{"text":"expert","s":26.602,"e":26.922},{"text":"would","s":27.002,"e":27.082},{"text":"need,","s":27.162,"e":27.642},{"text":"and","s":27.722,"e":27.802},{"text":"nothing","s":27.962,"e":28.362},{"text":"they","s":28.442,"e":28.522},{"text":"wouldn't.","s":28.602,"e":29.322}]},{"template":"table","chapter":"Shapes of state","narration":"State can be a plain string, which is fine for one message. An array works for a sequence, like a conversation. But for most real decisions, use an object, so every part has a name and the relationships stay clear.","params":{"title":"Three shapes, one default","cols":["Shape","Good for","Example"],"widths":"0.8fr 1.2fr 2fr","rows":[{"cells":["string","one message","\"My card was charged twice.\""],"at":"plain string"},{"cells":["array","a sequence","[\"Hi\", \"My customer number is TS1337.\", …]"],"at":"array"},{"cells":["*object*","*most real decisions*","{ticket: …, order: …, refund_policy: …}"],"hl":true,"at":"use an object"}]},"start":29.921,"dur":15.056,"words":[{"text":"State","s":30.221,"e":30.581},{"text":"can","s":30.621,"e":30.754},{"text":"be","s":30.781,"e":30.901},{"text":"a","s":30.941,"e":30.981},{"text":"plain","s":31.021,"e":31.421},{"text":"string,","s":31.501,"e":32.141},{"text":"which","s":32.221,"e":32.301},{"text":"is","s":32.381,"e":32.461},{"text":"fine","s":32.541,"e":32.781},{"text":"for","s":32.861,"e":33.021},{"text":"one","s":33.101,"e":33.181},{"text":"message.","s":33.261,"e":33.821},{"text":"An","s":34.221,"e":34.301},{"text":"array","s":34.381,"e":34.781},{"text":"works","s":34.861,"e":35.101},{"text":"for","s":35.181,"e":35.261},{"text":"a","s":35.301,"e":35.341},{"text":"sequence,","s":35.421,"e":36.061},{"text":"like","s":36.141,"e":36.301},{"text":"a","s":36.381,"e":36.421},{"text":"conversation.","s":36.461,"e":37.261},{"text":"But","s":37.741,"e":37.821},{"text":"for","s":37.901,"e":37.981},{"text":"most","s":38.061,"e":38.381},{"text":"real","s":38.541,"e":38.701},{"text":"decisions,","s":38.781,"e":39.581},{"text":"use","s":39.661,"e":39.821},{"text":"an","s":39.901,"e":40.061},{"text":"object,","s":40.141,"e":40.861},{"text":"so","s":40.941,"e":41.101},{"text":"every","s":41.181,"e":41.421},{"text":"part","s":41.501,"e":41.741},{"text":"has","s":41.821,"e":41.901},{"text":"a","s":41.941,"e":41.981},{"text":"name","s":42.061,"e":42.381},{"text":"and","s":42.461,"e":42.541},{"text":"the","s":42.581,"e":42.621},{"text":"relationships","s":43.021,"e":43.421},{"text":"stay","s":43.541,"e":43.661},{"text":"clear.","s":43.741,"e":44.381}]},{"template":"request","chapter":"Point at the field","narration":"Then point each question at the field it's about, with a path in backticks. Does the policy support the refund requested in the ticket, given the order's charges? The model knows exactly which parts to compare.","params":{"model":"jev-1.13.0","latency":0.25,"state":{"ticket":{"text":"I was charged twice for order A-104. Please refund the duplicate."},"order":{"id":"A-104","charges_usd":[49,49]},"refund_policy":"Duplicate charges are always refunded in full."},"questions":[{"id":"asks","type":"noul","text":"Does `ticket.text` request a refund?","ans":{"v":0.99}},{"id":"policy","type":"noul","text":"Does `refund_policy` support the refund requested in `ticket.text`, given `order.charges_usd`?","ans":{"v":0.98},"at":"Does the policy support"}],"send_at":"The model knows","ans_at":"exactly which parts","hl":"policy","hl_at":"compare"},"start":44.977,"dur":13.149,"words":[{"text":"Then","s":45.277,"e":45.487},{"text":"point","s":45.517,"e":45.789},{"text":"each","s":45.837,"e":46.097},{"text":"question","s":46.157,"e":46.637},{"text":"at","s":46.717,"e":46.797},{"text":"the","s":46.837,"e":46.877},{"text":"field","s":47.037,"e":47.277},{"text":"it's","s":47.357,"e":47.57},{"text":"about,","s":47.704,"e":47.997},{"text":"with","s":48.077,"e":48.157},{"text":"a","s":48.21,"e":48.264},{"text":"path","s":48.317,"e":48.557},{"text":"in","s":48.637,"e":48.717},{"text":"backticks.","s":48.797,"e":49.517},{"text":"Does","s":49.917,"e":49.997},{"text":"the","s":50.077,"e":50.157},{"text":"policy","s":50.357,"e":50.557},{"text":"support","s":50.637,"e":51.037},{"text":"the","s":51.077,"e":51.117},{"text":"refund","s":51.197,"e":51.597},{"text":"requested","s":51.877,"e":52.157},{"text":"in","s":52.197,"e":52.237},{"text":"the","s":52.277,"e":52.317},{"text":"ticket,","s":52.397,"e":52.957},{"text":"given","s":53.077,"e":53.197},{"text":"the","s":53.237,"e":53.277},{"text":"order's","s":53.397,"e":53.677},{"text":"charges?","s":53.957,"e":54.317},{"text":"The","s":54.717,"e":54.797},{"text":"model","s":54.917,"e":55.037},{"text":"knows","s":55.117,"e":55.357},{"text":"exactly","s":55.437,"e":56.077},{"text":"which","s":56.157,"e":56.317},{"text":"parts","s":56.397,"e":56.637},{"text":"to","s":56.677,"e":56.717},{"text":"compare.","s":56.797,"e":57.517}]},{"template":"chart","chapter":"Bury it, lose it","narration":"How much does extra material hurt? We tested sixty banking messages, half of them about refunds, with one Noul: does the ticket ask about a refund? Alone, ninety eight percent right. With six thousand tokens of unrelated handbook in its own field: still ninety eight. But bury the same ticket among forty similar tickets and ask about ticket number seventeen, and it drops to seventy two, missing seventeen of the thirty refund requests.","params":{"title":"“Does the ticket ask about a refund?” (60 messages)","kind":"bar","ymax":1.12,"data":[{"x":"ticket alone","y":0.983,"label":"98.3%","at":"Alone"},{"x":"+ 6k tokens unrelated, own field","y":0.983,"label":"98.3%","at":"still ninety eight"},{"x":"buried among 40, by index","y":0.717,"label":"71.7%","tone":"bad","hl":true,"at":"drops to seventy two"}],"src":"BANKING77 messages, jev-1.13.0, measured 2026-10-15. All 17 errors were missed refunds."},"start":58.126,"dur":30.259,"words":[{"text":"How","s":58.426,"e":58.666},{"text":"much","s":58.786,"e":58.906},{"text":"does","s":58.986,"e":59.146},{"text":"extra","s":59.306,"e":59.546},{"text":"material","s":59.626,"e":60.106},{"text":"hurt?","s":60.266,"e":60.746},{"text":"We","s":61.226,"e":61.386},{"text":"tested","s":61.626,"e":61.866},{"text":"sixty","s":61.946,"e":62.266},{"text":"banking","s":62.346,"e":62.666},{"text":"messages,","s":62.746,"e":63.546},{"text":"half","s":63.666,"e":63.786},{"text":"of","s":63.826,"e":63.866},{"text":"them","s":63.946,"e":64.026},{"text":"about","s":64.146,"e":64.266},{"text":"refunds,","s":64.346,"e":65.066},{"text":"with","s":65.186,"e":65.306},{"text":"one","s":65.386,"e":65.626},{"text":"Noul:","s":65.706,"e":66.506},{"text":"does","s":66.586,"e":66.666},{"text":"the","s":66.746,"e":66.786},{"text":"ticket","s":66.826,"e":67.146},{"text":"ask","s":67.226,"e":67.466},{"text":"about","s":67.546,"e":67.626},{"text":"a","s":67.706,"e":67.746},{"text":"refund?","s":67.786,"e":68.346},{"text":"Alone,","s":68.746,"e":69.546},{"text":"ninety","s":69.626,"e":69.946},{"text":"eight","s":70.026,"e":70.106},{"text":"percent","s":70.186,"e":70.506},{"text":"right.","s":70.586,"e":71.146},{"text":"With","s":71.386,"e":71.546},{"text":"six","s":71.626,"e":71.786},{"text":"thousand","s":71.946,"e":72.186},{"text":"tokens","s":72.266,"e":72.666},{"text":"of","s":72.746,"e":72.826},{"text":"unrelated","s":72.906,"e":73.466},{"text":"handbook","s":73.546,"e":73.946},{"text":"in","s":73.986,"e":74.026},{"text":"its","s":74.106,"e":74.186},{"text":"own","s":74.266,"e":74.426},{"text":"field:","s":74.506,"e":75.306},{"text":"still","s":75.386,"e":75.706},{"text":"ninety","s":75.786,"e":76.026},{"text":"eight.","s":76.106,"e":76.426},{"text":"But","s":76.986,"e":77.146},{"text":"bury","s":77.306,"e":77.546},{"text":"the","s":77.626,"e":77.786},{"text":"same","s":77.866,"e":78.106},{"text":"ticket","s":78.186,"e":78.506},{"text":"among","s":78.666,"e":78.826},{"text":"forty","s":78.986,"e":79.306},{"text":"similar","s":79.466,"e":79.786},{"text":"tickets","s":79.866,"e":80.266},{"text":"and","s":80.346,"e":80.506},{"text":"ask","s":80.626,"e":80.746},{"text":"about","s":80.826,"e":80.906},{"text":"ticket","s":80.986,"e":81.226},{"text":"number","s":81.306,"e":81.466},{"text":"seventeen,","s":81.546,"e":82.586},{"text":"and","s":82.626,"e":82.666},{"text":"it","s":82.746,"e":82.826},{"text":"drops","s":82.986,"e":83.146},{"text":"to","s":83.266,"e":83.386},{"text":"seventy","s":83.466,"e":83.786},{"text":"two,","s":83.946,"e":84.586},{"text":"missing","s":84.666,"e":84.986},{"text":"seventeen","s":85.146,"e":85.786},{"text":"of","s":85.866,"e":85.946},{"text":"the","s":86.026,"e":86.186},{"text":"thirty","s":86.266,"e":86.506},{"text":"refund","s":86.586,"e":86.906},{"text":"requests.","s":86.986,"e":87.786}]},{"template":"statement","chapter":"Bury it, lose it","narration":"So the lesson isn't just keep the state short. It's name the thing you're asking about. Don't make the model hunt for item seventeen in a list of lookalikes. Send that item on its own, or put it right in the question.","params":{"eyebrow":"The lesson","text":"Name the thing you're asking about. *Don't make it hunt.*","art":"snap","mood":"unsure","react":{"at":"Send that item","mood":"sure"},"punch":"name the thing"},"start":88.385,"dur":14.194,"words":[{"text":"So","s":88.685,"e":88.845},{"text":"the","s":88.925,"e":89.005},{"text":"lesson","s":89.165,"e":89.325},{"text":"isn't","s":89.405,"e":89.725},{"text":"just","s":89.885,"e":90.125},{"text":"keep","s":90.205,"e":90.365},{"text":"the","s":90.445,"e":90.485},{"text":"state","s":90.525,"e":90.845},{"text":"short.","s":90.925,"e":91.645},{"text":"It's","s":91.725,"e":92.045},{"text":"name","s":92.205,"e":92.445},{"text":"the","s":92.525,"e":92.605},{"text":"thing","s":92.685,"e":92.845},{"text":"you're","s":92.885,"e":93.005},{"text":"asking","s":93.085,"e":93.405},{"text":"about.","s":93.485,"e":94.285},{"text":"Don't","s":94.365,"e":94.525},{"text":"make","s":94.605,"e":94.685},{"text":"the","s":94.725,"e":94.765},{"text":"model","s":94.845,"e":95.085},{"text":"hunt","s":95.165,"e":95.405},{"text":"for","s":95.485,"e":95.565},{"text":"item","s":95.645,"e":95.885},{"text":"seventeen","s":96.045,"e":96.685},{"text":"in","s":96.765,"e":96.845},{"text":"a","s":96.872,"e":96.898},{"text":"list","s":96.925,"e":97.165},{"text":"of","s":97.205,"e":97.245},{"text":"lookalikes.","s":97.325,"e":98.365},{"text":"Send","s":98.445,"e":98.605},{"text":"that","s":98.685,"e":98.765},{"text":"item","s":98.845,"e":99.085},{"text":"on","s":99.165,"e":99.245},{"text":"its","s":99.365,"e":99.485},{"text":"own,","s":99.565,"e":100.045},{"text":"or","s":100.165,"e":100.285},{"text":"put","s":100.445,"e":100.525},{"text":"it","s":100.605,"e":100.765},{"text":"right","s":100.845,"e":101.005},{"text":"in","s":101.045,"e":101.085},{"text":"the","s":101.125,"e":101.165},{"text":"question.","s":101.245,"e":101.965}]},{"template":"code","chapter":"Data in the question","narration":"Questions can carry data too. To check a new resume against candidate records, put each record inside its own question's instructions, next to the same question text. Twenty records, twenty Nouls, one request, and each answer is about exactly one record.","params":{"file":"duplicates.py","lang":"py","lines":["SAME = \"Is the resume for the same person as `potential_duplicate`?\"","","questions = {","    f\"same_as_{c['id']}\": Noul(instructions={","        \"potential_duplicate\": {\"name\": c[\"name\"],","                                \"location\": c[\"location\"]},","        \"question\": SAME,","    })","    for c in candidates          # one question per record","}","client.system_one(state={\"resume\": resume}, questions=questions)"],"hl":[{"from":4,"to":8,"label":"the record rides with its question","tone":"agent","at":"inside its own question"},{"from":11,"to":11,"label":"one request","tone":"good","at":"one request"}]},"start":102.579,"dur":18.112,"words":[{"text":"Questions","s":102.879,"e":103.439},{"text":"can","s":103.519,"e":103.599},{"text":"carry","s":103.759,"e":103.919},{"text":"data","s":104.079,"e":104.239},{"text":"too.","s":104.319,"e":105.039},{"text":"To","s":105.119,"e":105.199},{"text":"check","s":105.279,"e":105.439},{"text":"a","s":105.492,"e":105.546},{"text":"new","s":105.599,"e":105.679},{"text":"resume","s":105.759,"e":106.159},{"text":"against","s":106.359,"e":106.559},{"text":"candidate","s":106.639,"e":107.039},{"text":"records,","s":107.279,"e":107.839},{"text":"put","s":107.919,"e":108.079},{"text":"each","s":108.159,"e":108.399},{"text":"record","s":108.599,"e":108.799},{"text":"inside","s":108.999,"e":109.199},{"text":"its","s":109.319,"e":109.439},{"text":"own","s":109.519,"e":109.759},{"text":"question's","s":109.959,"e":110.239},{"text":"instructions,","s":110.639,"e":111.199},{"text":"next","s":111.279,"e":111.439},{"text":"to","s":111.519,"e":111.599},{"text":"the","s":111.679,"e":111.759},{"text":"same","s":111.839,"e":112.079},{"text":"question","s":112.239,"e":112.559},{"text":"text.","s":112.639,"e":113.519},{"text":"Twenty","s":113.639,"e":113.759},{"text":"records,","s":113.839,"e":114.639},{"text":"twenty","s":114.759,"e":114.879},{"text":"Nouls,","s":114.959,"e":115.759},{"text":"one","s":115.839,"e":115.919},{"text":"request,","s":115.999,"e":116.879},{"text":"and","s":116.999,"e":117.119},{"text":"each","s":117.199,"e":117.359},{"text":"answer","s":117.439,"e":117.759},{"text":"is","s":117.839,"e":117.919},{"text":"about","s":117.999,"e":118.239},{"text":"exactly","s":118.399,"e":118.959},{"text":"one","s":119.119,"e":119.279},{"text":"record.","s":119.519,"e":120.079}]},{"template":"list","chapter":"Limits to design around","narration":"A few limits to design around. Question IDs aren't sent to the model, so write the full question in the instructions. Jev reads up to sixty four thousand tokens per request, and thirty two thousand for the state plus any one question. Long context can be turned on, but TypeSafe warns it's slower and less accurate. And English is still the strongest language, so test others before you rely on them.","params":{"title":"Design around these","style":"warn","items":[{"text":"**IDs aren't sent.** Write the whole question in `instructions`.","at":"IDs"},{"text":"**64k tokens** per request, **32k** for state + one question.","at":"sixty four thousand"},{"text":"**Long context** exists, but it's slower and less accurate.","at":"Long context"},{"text":"**English first.** Test other languages before relying on them.","at":"English"}]},"start":120.691,"dur":26.681,"words":[{"text":"A","s":120.991,"e":121.151},{"text":"few","s":121.231,"e":121.391},{"text":"limits","s":121.471,"e":121.871},{"text":"to","s":121.911,"e":121.951},{"text":"design","s":122.031,"e":122.351},{"text":"around.","s":122.591,"e":123.071},{"text":"Question","s":123.311,"e":123.631},{"text":"IDs","s":123.711,"e":124.271},{"text":"aren't","s":124.351,"e":124.591},{"text":"sent","s":124.671,"e":124.911},{"text":"to","s":124.951,"e":124.991},{"text":"the","s":125.031,"e":125.071},{"text":"model,","s":125.151,"e":125.631},{"text":"so","s":125.711,"e":125.871},{"text":"write","s":126.031,"e":126.271},{"text":"the","s":126.311,"e":126.351},{"text":"full","s":126.511,"e":126.671},{"text":"question","s":126.831,"e":127.231},{"text":"in","s":127.311,"e":127.391},{"text":"the","s":127.431,"e":127.471},{"text":"instructions.","s":127.871,"e":128.351},{"text":"Jev","s":128.751,"e":128.991},{"text":"reads","s":129.071,"e":129.311},{"text":"up","s":129.391,"e":129.471},{"text":"to","s":129.591,"e":129.711},{"text":"sixty","s":129.831,"e":130.031},{"text":"four","s":130.111,"e":130.271},{"text":"thousand","s":130.511,"e":130.911},{"text":"tokens","s":130.991,"e":131.391},{"text":"per","s":131.471,"e":131.551},{"text":"request,","s":131.631,"e":132.271},{"text":"and","s":132.391,"e":132.511},{"text":"thirty","s":132.591,"e":132.751},{"text":"two","s":132.911,"e":132.991},{"text":"thousand","s":133.071,"e":133.391},{"text":"for","s":133.471,"e":133.551},{"text":"the","s":133.591,"e":133.631},{"text":"state","s":133.791,"e":134.111},{"text":"plus","s":134.191,"e":134.511},{"text":"any","s":134.591,"e":134.831},{"text":"one","s":134.911,"e":135.071},{"text":"question.","s":135.151,"e":135.911},{"text":"Long","s":136.111,"e":136.351},{"text":"context","s":136.431,"e":136.911},{"text":"can","s":136.991,"e":137.151},{"text":"be","s":137.231,"e":137.311},{"text":"turned","s":137.391,"e":137.631},{"text":"on,","s":137.711,"e":138.191},{"text":"but","s":138.311,"e":138.431},{"text":"TypeSafe","s":138.511,"e":138.991},{"text":"warns","s":139.071,"e":139.391},{"text":"it's","s":139.471,"e":139.631},{"text":"slower","s":139.711,"e":140.191},{"text":"and","s":140.271,"e":140.351},{"text":"less","s":140.431,"e":140.591},{"text":"accurate.","s":140.671,"e":141.551},{"text":"And","s":141.671,"e":141.791},{"text":"English","s":141.951,"e":142.351},{"text":"is","s":142.431,"e":142.591},{"text":"still","s":142.711,"e":142.831},{"text":"the","s":142.911,"e":142.991},{"text":"strongest","s":143.071,"e":143.391},{"text":"language,","s":143.471,"e":144.111},{"text":"so","s":144.231,"e":144.351},{"text":"test","s":144.511,"e":144.751},{"text":"others","s":144.831,"e":145.151},{"text":"before","s":145.351,"e":145.551},{"text":"you","s":145.631,"e":145.711},{"text":"rely","s":145.751,"e":146.031},{"text":"on","s":146.111,"e":146.191},{"text":"them.","s":146.311,"e":146.751}]},{"template":"statement","chapter":"Facts vs judgments","narration":"One last habit, from TypeSafe's own guide for coding agents. When you store answers and feed them into later requests, keep what you observed separate from what the model inferred. A field that says refund requested, point nine nine, is a judgment, not a fact. Label it, and check it's still fresh before you act on it.","params":{"eyebrow":"TypeSafe agent skill","text":"Keep *inferred* state distinct from *observed* facts.","sub":"A stored “refund_requested: 0.99” is a judgment. Label it, and re-check it if the situation changed.","sub_at":"is a judgment","art":"curly","punch":"observed"},"start":147.372,"dur":21.796,"words":[{"text":"One","s":147.672,"e":147.912},{"text":"last","s":148.072,"e":148.232},{"text":"habit,","s":148.432,"e":148.952},{"text":"from","s":149.032,"e":149.112},{"text":"TypeSafe's","s":149.192,"e":149.832},{"text":"own","s":149.952,"e":150.072},{"text":"guide","s":150.152,"e":150.392},{"text":"for","s":150.472,"e":150.552},{"text":"coding","s":150.632,"e":150.872},{"text":"agents.","s":150.952,"e":151.512},{"text":"When","s":151.992,"e":152.152},{"text":"you","s":152.232,"e":152.312},{"text":"store","s":152.472,"e":152.632},{"text":"answers","s":152.712,"e":153.192},{"text":"and","s":153.272,"e":153.352},{"text":"feed","s":153.432,"e":153.672},{"text":"them","s":153.752,"e":153.832},{"text":"into","s":153.952,"e":154.072},{"text":"later","s":154.152,"e":154.392},{"text":"requests,","s":154.712,"e":155.432},{"text":"keep","s":155.512,"e":155.672},{"text":"what","s":155.752,"e":155.832},{"text":"you","s":155.872,"e":155.912},{"text":"observed","s":155.992,"e":156.552},{"text":"separate","s":156.792,"e":157.192},{"text":"from","s":157.272,"e":157.432},{"text":"what","s":157.512,"e":157.592},{"text":"the","s":157.632,"e":157.672},{"text":"model","s":157.752,"e":157.992},{"text":"inferred.","s":158.072,"e":158.712},{"text":"A","s":159.192,"e":159.272},{"text":"field","s":159.352,"e":159.592},{"text":"that","s":159.672,"e":159.752},{"text":"says","s":159.832,"e":160.152},{"text":"refund","s":160.392,"e":160.792},{"text":"requested,","s":161.112,"e":161.592},{"text":"point","s":161.712,"e":161.832},{"text":"nine","s":161.912,"e":162.072},{"text":"nine,","s":162.152,"e":162.792},{"text":"is","s":162.832,"e":162.872},{"text":"a","s":162.952,"e":163.032},{"text":"judgment,","s":163.112,"e":163.912},{"text":"not","s":163.992,"e":164.152},{"text":"a","s":164.192,"e":164.232},{"text":"fact.","s":164.312,"e":164.792},{"text":"Label","s":165.272,"e":165.512},{"text":"it,","s":165.592,"e":165.912},{"text":"and","s":165.992,"e":166.072},{"text":"check","s":166.152,"e":166.312},{"text":"it's","s":166.392,"e":166.552},{"text":"still","s":166.632,"e":166.712},{"text":"fresh","s":166.872,"e":167.192},{"text":"before","s":167.272,"e":167.512},{"text":"you","s":167.552,"e":167.592},{"text":"act","s":167.672,"e":167.912},{"text":"on","s":167.992,"e":168.072},{"text":"it.","s":168.192,"e":168.552}]},{"template":"quiz","chapter":"Quick check","narration":"Quick check. You need to know whether ticket seventeen, in a batch of forty, asks for a refund. What's the best state?","params":{"q":"Is **ticket 17 of 40** asking for a refund? Best state?","options":["All 40 tickets in an array; ask about `tickets[17]`","All 40 tickets plus the refund policy, for context","Ticket 17 alone, as a named field; ask about that field","A summary of all 40 tickets"],"answer":2,"explain":"In our test, asking about one ticket by index among 40 lookalikes missed 17 of 30 refunds. Send the item you're asking about on its own, under a clear name."},"start":169.168,"dur":13.128,"words":[{"text":"Quick","s":169.468,"e":169.708},{"text":"check.","s":169.788,"e":170.308},{"text":"You","s":170.508,"e":170.588},{"text":"need","s":170.668,"e":170.748},{"text":"to","s":170.828,"e":170.868},{"text":"know","s":170.908,"e":171.068},{"text":"whether","s":171.188,"e":171.308},{"text":"ticket","s":171.388,"e":171.708},{"text":"seventeen,","s":171.788,"e":172.668},{"text":"in","s":172.708,"e":172.748},{"text":"a","s":172.788,"e":172.828},{"text":"batch","s":172.948,"e":173.068},{"text":"of","s":173.148,"e":173.228},{"text":"forty,","s":173.308,"e":173.948},{"text":"asks","s":174.148,"e":174.348},{"text":"for","s":174.388,"e":174.428},{"text":"a","s":174.508,"e":174.588},{"text":"refund.","s":174.668,"e":175.628},{"text":"What's","s":175.708,"e":175.868},{"text":"the","s":175.908,"e":175.948},{"text":"best","s":176.108,"e":176.348},{"text":"state?","s":176.588,"e":177.148}]},{"template":"exercise","chapter":"Try it","narration":"Try it. Have your agent design the state for one decision in your code, and test what happens when you bury it.","params":{"title":"Design a state, then bury it","intro":"Paste this into your coding agent:","prompt":"Pick one decision we make with a model. Design its state as a JSON\nobject with named fields: only what an expert would need (the message,\nthe record, the relevant policy). Rewrite each question to point at its\nfield with a backticked path. Then run 20 labeled examples three ways:\nthe clean state, the state plus a large unrelated document in its own\nfield, and the item hidden in a list of 20 similar items. Report the\naccuracy of each."},"start":182.296,"dur":7.376,"words":[{"text":"Try","s":182.596,"e":182.836},{"text":"it.","s":182.916,"e":183.356},{"text":"Have","s":183.556,"e":183.716},{"text":"your","s":183.796,"e":183.876},{"text":"agent","s":183.956,"e":184.196},{"text":"design","s":184.396,"e":184.596},{"text":"the","s":184.636,"e":184.676},{"text":"state","s":184.756,"e":185.076},{"text":"for","s":185.196,"e":185.316},{"text":"one","s":185.396,"e":185.556},{"text":"decision","s":185.796,"e":186.036},{"text":"in","s":186.076,"e":186.116},{"text":"your","s":186.196,"e":186.276},{"text":"code,","s":186.356,"e":186.836},{"text":"and","s":186.956,"e":187.076},{"text":"test","s":187.156,"e":187.396},{"text":"what","s":187.476,"e":187.556},{"text":"happens","s":187.636,"e":187.956},{"text":"when","s":188.036,"e":188.116},{"text":"you","s":188.196,"e":188.276},{"text":"bury","s":188.436,"e":188.596},{"text":"it.","s":188.716,"e":189.076}]},{"template":"recap","chapter":"Recap","narration":"So: state is what you'd hand an expert panel. Use named fields and point questions at them. Name the thing you're asking about, and never make the model hunt for it. Design around the limits, and keep judgments separate from facts. That's module two. Next: probabilities you can act on, starting with calibration.","params":{"items":["State = what you'd hand an expert panel. Use a named object.","Point questions at fields with backticked paths.","Name the thing you're asking about; never make it hunt.","IDs aren't sent; long context is slower; English is strongest."],"next":"Calibration: does 0.9 mean 90%?","next_at":"Next"},"start":189.672,"dur":22.328,"words":[{"text":"So:","s":189.972,"e":190.772},{"text":"state","s":190.852,"e":191.252},{"text":"is","s":191.332,"e":191.412},{"text":"what","s":191.452,"e":191.492},{"text":"you'd","s":191.572,"e":191.732},{"text":"hand","s":191.852,"e":191.972},{"text":"an","s":192.052,"e":192.132},{"text":"expert","s":192.332,"e":192.532},{"text":"panel.","s":192.612,"e":193.412},{"text":"Use","s":193.492,"e":193.732},{"text":"named","s":193.812,"e":194.132},{"text":"fields","s":194.212,"e":194.612},{"text":"and","s":194.692,"e":194.772},{"text":"point","s":194.892,"e":195.012},{"text":"questions","s":195.092,"e":195.492},{"text":"at","s":195.572,"e":195.732},{"text":"them.","s":195.852,"e":196.452},{"text":"Name","s":196.532,"e":196.772},{"text":"the","s":196.852,"e":196.932},{"text":"thing","s":197.012,"e":197.092},{"text":"you're","s":197.132,"e":197.252},{"text":"asking","s":197.332,"e":197.572},{"text":"about,","s":197.652,"e":198.052},{"text":"and","s":198.212,"e":198.372},{"text":"never","s":198.452,"e":198.692},{"text":"make","s":198.772,"e":198.932},{"text":"the","s":198.972,"e":199.012},{"text":"model","s":199.092,"e":199.332},{"text":"hunt","s":199.412,"e":199.572},{"text":"for","s":199.652,"e":199.812},{"text":"it.","s":199.932,"e":200.452},{"text":"Design","s":200.652,"e":200.852},{"text":"around","s":200.932,"e":201.252},{"text":"the","s":201.332,"e":201.372},{"text":"limits,","s":201.412,"e":201.972},{"text":"and","s":202.052,"e":202.132},{"text":"keep","s":202.212,"e":202.372},{"text":"judgments","s":202.452,"e":203.012},{"text":"separate","s":203.052,"e":203.412},{"text":"from","s":203.492,"e":203.572},{"text":"facts.","s":203.652,"e":204.532},{"text":"That's","s":204.612,"e":204.852},{"text":"module","s":205.012,"e":205.172},{"text":"two.","s":205.252,"e":205.972},{"text":"Next:","s":206.052,"e":206.852},{"text":"probabilities","s":206.972,"e":207.572},{"text":"you","s":207.652,"e":207.732},{"text":"can","s":207.852,"e":207.972},{"text":"act","s":208.092,"e":208.212},{"text":"on,","s":208.292,"e":208.772},{"text":"starting","s":208.972,"e":209.172},{"text":"with","s":209.252,"e":209.332},{"text":"calibration.","s":209.412,"e":210.452}]}],"total":212.4,"audio":"/audio/08-state.mp3"}