feat: add Codex-style lifecycle hooks#10
Merged
Conversation
Allow hook configs to forward named parent environment variables and define literal hook environment values while preserving the cleared-env default for credentials.
Drop the outer tool runtime context before waiting for the event-drain future so the mpsc channel closes once the agent future returns. This lets turns finish, save transcripts, run stop hooks, and return to raw input mode.
Ignore reasoning deltas for response layout when the reasoning panel is disabled. This prevents models that stream thinking fields from repeatedly closing and reopening the visible response block.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This adds Codex-style lifecycle hooks to Small Harness.
Hooks let local commands observe or influence harness events: session start/end, prompt submission, tool use, permission requests, compaction, plan updates, subagent start/stop, and stop events.
Demo
The first concrete integration is Zentty agent status, shown in the demo below.
Zentty.2026-06-16.21-26-07.mp4
Codex-style hook model
The hook model follows Codex closely:
allow,deny,block, andstopupdatedInput,additionalContext, andfeedback2maps to a blocking decision/hookslists configured hooks and manages trustProject hooks do not run just because a repo config declares them. They must be reviewed and trusted by current definition hash first. If the hook definition changes, it is treated as modified and skipped until trusted again. Project-controlled hook state is ignored.
This also adds process-local managed launch hooks through
SMALL_HARNESS_MANAGED_HOOKS_JSONandSMALL_HARNESS_MANAGED_HOOKS_FILE. These are for launchers that already own the Small Harness process, like Zentty. They are modeled after Codex managed hooks, but they are not Codex enterprise/MDM managed hooks or cryptographic signatures.Environment forwarding
Hook subprocesses still start from a cleared environment by default. That keeps provider credentials out of hooks unless a hook explicitly asks for them.
For launcher integrations, hooks can now use:
envfor literal valuesenvVarsto forward selected parent process variablesThat lets a Zentty hook receive only the socket, worklane, pane, and pane token values it needs to report status back to the sidebar.
Hook hardening
This also includes a few safety details around hook execution:
/hooksbut skippedPreToolUseandPermissionRequestrunner failures fail closedSmall fixes included
Two small fixes came out while testing this branch:
Test plan
cargo fmt --checkcargo test hooks::testscargo test