[{"data":1,"prerenderedAt":174},["ShallowReactive",2],{"project-49006862":3},{"id":4,"name":5,"line":5,"line_source":6,"title":7,"url":8,"domain":9,"maker":10,"posted_at":11,"year":12,"points":13,"comments":14,"rank_in_year":15,"shown_in_year":16,"top":17,"tier":18,"category":19,"subcategory":20,"format":21,"keywords":22,"reception":28,"sentiment":29,"stance_mix":30,"scored_comments":31,"aspects":32,"strip":35,"post_text":37,"what":38,"said":66,"maker_in_thread":101,"shape":114,"grid":118,"attempts":137,"same_week":138,"maker_shows":103,"maker_hidden":167,"reader_version":168,"card":169},"49006862","Agent in 9 Lines Python","title","Show HN: Agent in 9 Lines Python","https:\u002F\u002Fgist.github.com\u002Ftosh\u002F6e91a9dbf08dd630c535e7345ac7f0b5","gist.github.com","tosh",1784728343,2026,21,9,1964,4366,45,"shown","ai","agent harness","cli",[23,24,25,26,27],"ai agent","tool calling","python agent","minimal agent","openai-compatible api","curious",0,{"positive":29,"neutral":31,"mixed":29,"critical":29},5,{"docs":33,"design":34},{"positive":29,"critical":29},{"positive":29,"critical":29},[36,29,36,29,36,29,36,36,29],3,"I asked myself: what would a minimal implementation of an agent look like?\n\nSomething that works out of the box, is a real agent with tool calling, but without 1000s of lines of code, without dozens or hundreds of npm or pypi dependencies. Something with just a few 'essential' features (not a whole kitchen sink that most agent harnesses come with nowadays).\n\nAn implementation close to pseudocode that you can look at in one page, everything there at a glance, no scrolling.\n\nThis is the agent.py I ended up with so far:\n\n\n```\n  import json,sys;from subprocess import getoutput as sh;from urllib.re",{"problem":39,"audience":45,"pricing":50,"motivation":51,"time_to_build":50,"stack":55,"openness":64,"stage":65,"team_size":65},{"value":40,"source":41,"evidence":42},"Agent harnesses are bloated with many dependencies and features; a minimal agent is wanted.","maker",[43],{"id":44},"post",{"value":46,"source":47,"evidence":48},"Developers who want a small, readable agent implementation.","inferred",[49],{"id":44},null,{"value":52,"source":41,"evidence":53},"Wanted to see what a minimal agent with tool calling would look like.",[54],{"id":44},[56,60],{"value":57,"source":41,"evidence":58},"Python stdlib",[59],{"id":44},{"value":61,"source":41,"evidence":62},"OpenAI-compatible inference API",[63],{"id":44},"open_source","unknown",{"praise":67,"objections":76,"requests":81,"questions":95,"alternatives":100},[68],{"value":69,"source":70,"evidence":71},"Compact yet readable design.","commenter",[72],{"id":73,"by":74,"text":75},"49007314","JSR_FDED","Super cool for how compact yet still readable it is. Shouldn’t there be a tool description passed to the LLM though?",[77],{"value":78,"source":70,"evidence":79},"Tool description missing from the LLM setup.",[80],{"id":73,"by":74,"text":75},[82,89],{"value":83,"source":70,"evidence":84},"Ungolfed or more readable version.",[85],{"id":86,"by":87,"text":88},"49009880","gabrielsroka","Nice. Do you have an ungolfed version? I was going to ask my LLM to make one.",{"value":90,"source":70,"evidence":91},"Simplify code further and make it clearer.",[92],{"id":93,"by":87,"text":94},"49010259","ty. a little easier to read. i'd move the headers out of the loop (u can prolly just hard-code it), and move context_usage to inside the if (and maybe hard-code it, too)",[96],{"value":97,"source":70,"evidence":98},"Does the tool need a description passed to the model?",[99],{"id":73,"by":74,"text":75},[],{"comments":102,"answered":103,"key":104},4,2,[105,108,111],{"id":106,"text":107},"49010120","here is a more expanded transliteration: https:\u002F\u002Fgist.github.com\u002Ftosh\u002F61aca9ffa9ea115fa4df332407d7a9a9",{"id":109,"text":110},"49010570","oh right, good point @ move outside of the loop (or move directly into the Request), ty!",{"id":112,"text":113},"49017375","ty for looking into it, i like your http.client take (still stdlib, keeps connection open)",{"commenters":36,"max_depth":115,"maker_replies":102,"first_comment_mins":116,"lifespan_hours":117},7,29,39,[119,121,124,125,126,128,130,133,135],[86,29,36,120,87,29],"maker\u002Fneutral\u002Fdocs",[106,29,29,122,10,123],"maker\u002Fpositive\u002Fdocs",1,[93,29,36,120,87,29],[109,29,29,122,10,123],[127,29,36,120,87,29],"49014660",[112,29,29,129,10,123],"maker\u002Fpositive\u002Fexecution",[131,29,36,132,87,29],"49031318","maker\u002Fneutral\u002Fnone",[73,123,36,134,74,29],"project\u002Fneutral\u002Fdesign",[136,123,29,134,10,123],"49009274",[],[139,144,149,153,158,163],{"id":140,"name":141,"points":142,"category":143},"48968606","I replaced a $120k bowling center system with $1,600 in ESP32s",2935,"hardware",{"id":145,"name":146,"points":147,"category":148},"49008211","Bento",1033,"creative",{"id":150,"name":151,"points":152,"category":148},"48984254","Grace Cathedral Gaussian Splat tour",263,{"id":154,"name":155,"points":156,"category":157},"49008406","HN Hall of Fame",219,"consumer_social",{"id":159,"name":160,"points":161,"category":162},"48946738","Justif",198,"languages",{"id":164,"name":165,"points":166,"category":19},"49010782","Cactus Hybrid",191,false,"v2",{"id":170,"name":5,"line":5,"ai":167,"cat":19,"year":12,"points":13,"comments":14,"rec":28,"s":29,"top":17,"kw":171,"maker":10,"domain":9,"tier":18,"attempts":29,"strip":172,"url":8,"mix":173,"praise":69,"objection":78,"sub":20},49006862,[23,24,25,26,27],"303030330",[29,31,29,29],1794036705670]