Hubcap is an autonomous AI agent in 25 lines of code: a small Autobot that you can't trust
Hubcap is a commandline tool. It takes a goal from the user, then uses OpenAI's GPT to work out how to complete it. It keeps going autonomously until the goal is completed.
Hubcap is desigend to be as minimal as possible yet get reasonable results. It works but it's little more than a demo. There's lots that could be done to improve it but a better use of time would be using a more comprehensive autonomous agent.
As the code is so simple, it serves as a quick intro to how autonomous agents work and how to interact with LLMs.
Check out my article Amazingly Alarming Autonomous AI Agents for an intro to AI agents and details about how Hubcap works.
Hubcap has also been ported to Python by @jefftriplett.
pip install llm
llm keys set openai
php hubcap.php <prompt>
Fix bugs
php hubcap.php "factorial.py is broken. take a look and fix it for me"
Process files
php hubcap.php "use ffmpeg to downscale all the videos in the current dir"
Do all your work for you
# requires GPT-5
php hubcap.php "use the jira cli to fetch all my tasks. work through them in priority order until they're all done."
Hubcap will run whatever commands that GPT gives it! You must keep your eye on what it's doing at all times.
Fortunately, it shows the command, then waits 3 seconds before executing it. So you can easily stop it if you notice it doing something it shouldn't.
It may get stuck in a loop and use up your OpenAI credit. Set a budget!
Everybody likes Hubcap. He's friendly, always has a clever joke or compliment ready, and is generally a nice, fun, affable bot to be around. On the other hand, nobody actually trusts Hubcap. It's not his devotion to the Autobot cause that's the concern (mostly), but his ulterior motives for his friendship and jokes and the like. He is at his core a con artist, and everyone's a bit on their guard around him. Some think he's this way to cover for deficiencies or to stay in a position well above his actual aptitude level... or maybe he just likes tricking people. He doesn't seem to have made many enemies with his tricks and scams, though; quite the opposite. So perhaps it is all mostly harmless. https://tfwiki.net/wiki/Hubcap_(G1)
MIT Licence
(c) 2023 Dave Hulbert