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."
![fixing python script](https://private-user-images.githubusercontent.com/50682/260571565-1e6a535f-a03f-4e2f-9cb1-d23b412efeca.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYwMjkyNzgsIm5iZiI6MTcyNjAyODk3OCwicGF0aCI6Ii81MDY4Mi8yNjA1NzE1NjUtMWU2YTUzNWYtYTAzZi00ZTJmLTljYjEtZDIzYjQxMmVmZWNhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTExVDA0MjkzOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBmODgzM2Q1N2Q3NTIwYzgzODVhOGJmYWM1MmE5OWNkOGVhMzg2ZGY0ZGEwN2VjYTFkNzRhNjEwYTQ2ODFhYWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ON751sBOAyzKoIWfOevw2Tm7Hv29MwOY5DD8zGKlRxQ)
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