Managing Hooks
Last updated
Where installed hook scripts are listed, opened and removed, and how the agent writes them.
Managing hook files
Since v1.4.1 the installed scripts can be managed outside the agent:
| Surface | What it does |
|---|---|
TUI /hook | Lists every installed <state>.py / <state>.js; when a state has both, the .py is marked (primary) in blue. Enter opens the file, d moves it to ~/.config/agenvoy/hooks/.Trash (recorded in file history). With nothing installed the popup says so and Enter opens the hooks folder |
| Web UI Hooks tab | Always lists all seven states by name (BeforeUserSend ... AfterTaskCancel), with not added or the installed languages under each. A state has a .py and a .js tab, .py first; a file that does not exist yet is labeled (new) and prefilled with its demo. Save writes the open tab, Delete trashes it and Open opens it with the system default app (both disabled for a (new) file); unsaved edits are kept while switching tabs |
| REST | GET /v1/hooks, GET /v1/hook/*name, PUT /v1/hook, DELETE /v1/hook, all local — see Role, Skill, Hook and Allowlist Endpoints |
These all act on ~/.config/agenvoy/hooks/, the only hooks directory.
Writing hooks with the agent
The agent writes hooks through three tools (see Skill and Hook Tools):
read_hook returns the state's demo and the installed hook, write_hook writes, patches or trashes the script, and test_hook runs it once with sample stdin. Since v1.5.0 both ask for confirmation under safe and run without one under auto or allow this turn (before v1.5.0 they never asked); mode=remove always asks. The hook topic of reasoning_guide gives the order: read, write or patch, then test and fix until test_hook returns the expected success. Subagents and scheduled runs cannot use write_hook or test_hook.