zenity(1) for AI agents to ask for sudo
- Updated
- Created
- Reading time
- 4 min read
Few words about the environment
I have a Thinkpad as my home lab central server that is running inside my local network. Apart from running other, non-graphical stuff there I usually keep an open RustDesk connection to do some maintenance or to modify my nixOS settings.
I like to have a peep what is being done in the background when watching a Netflix series or physically sit in front of it, click the best laptop keyboard (yes) and look at the horrible LCD screen running i3-wm. For the love of the game I guess.
In contrary to my main work machine, on Thinkpad - AI agents run there with full permissions granted. I treat that device as an ephemeral computing environment. There is no stuff that could be broken there nor remote accesses that would ever allow important stuff being modified by not-supervised agent.[1]
Notes & references
More on that on upcoming post about my entire home lab setup
↩
The problem and inconvenience
Apart all of early "full access" claims, the agent will not execute sudo commands out of the box.. and during many agentic loop turns (especially when doing mentioned system maintenance) it becomes cumbersome to have
- Agent to stop the loop (that sometimes been running for ~1h).
- Agent to ask me to run certain stuff by hand, then to paste output to the chat.
For (obviously) I would never type and then save the password to any environment variable, command argument, file or chat. I doubt it could even be productively picked up by the agent's PTY.
The solution
zenity(1) - not only cool name of the utility. It is a stupidly simple and effective GTK-based GUI helper for shell scripts. It has been around with us for ~22 years [2]. We can make advantage of it by creating a sudo-runner wrapper script and AGENTS.md entry and guidelines.. or both!
nixOS wrapper command source
Agent's instructions in markdown
You can put that anywhere in your project where you want to use zenity for the same purpose I do. In my case, it is living inside AGENTS.md directly in my nixOS configuration.
This way stuff that needs explicit escalation can be prompted via zenity, along with the description and title to quickly have look of what is being done without crawling through the agent's transcript.
Notes & references
If you want to dig a bit into the history - I believe
↩zenityis a rewrite of GNOME 1'sgdialog. The project may started earlier though according to the Debian's package description, the archive of releases date back to 2004.

How does it look in practice
