alt.hn

7/22/2026 at 1:52:23 PM

Show HN: Agent in 9 Lines Python

https://gist.github.com/tosh/6e91a9dbf08dd630c535e7345ac7f0b5

by tosh

7/22/2026 at 5:01:12 PM

Nice.

Do you have an ungolfed version? I was going to ask my LLM to make one.

by gabrielsroka

7/22/2026 at 5:17:25 PM

here is a more expanded transliteration:

https://gist.github.com/tosh/61aca9ffa9ea115fa4df332407d7a9a...

by tosh

7/22/2026 at 5:25:52 PM

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)

by gabrielsroka

7/22/2026 at 5:43:38 PM

oh right, good point @ move outside of the loop (or move directly into the Request), ty!

by tosh

7/22/2026 at 2:21:46 PM

Super cool for how compact yet still readable it is. Shouldn’t there be a tool description passed to the LLM though?

by JSR_FDED

7/22/2026 at 4:22:59 PM

Great question!

I had a tool description earlier but 'sh' as tool name seems to be sufficient, the agent behaviour was the same.

There might be performance gains if a description is added though, or worth trying different ways of telling the agent about what is available in the environment.

That said, the newer models are fairly good at driving a harness to explore the environment.

by tosh