A local-first multi-agent app development platform, built on PenguinHarness
Hook packages follow the model context, and user_prompt hooks run on every prompt
- Date: 2026-09-29
- Type: feature
- Scope:
core,server,cli,plugins,docs - PR: #891
- Breaking: yes — an in-process
user_prompthook (SessionConfig.hooks.userPrompt) runs on every prompt unless it is markedtrigger: "host", andSession.runUserPromptHookfinds only hooks so marked
Hook packages became part of what a model context is assembled from, read again each time a context opens, and the user_prompt hook point started running on every prompt the user submits. The change let a package that an agent writes into its own agent_state/hooks/ during a conversation take effect at that conversation's next compaction instead of in the next conversation, and the agent-initialization skill was rewritten to teach an agent how to create, install and import Skills and hook packages.
Details
- Hooks follow the model context.
Agent.assembleContextreadagent_state/hooks/andhooks.enabledwhenever a context opened: at Session creation, in the context a compaction opens, and on resume.openNextContextreturned the new context's hooks asSessionOpenedContext.hooks, and the Session replaced its whole set with them (adoptHooks), empty lists included, so uninstalling the last package reached a running conversation too. Every consult read the Session's hooks when it happened, so a compaction inside oneruncall handed the rest of the call to the new context's hooks. The server kept invalidating an agent's cached runtimes when a hook package was installed, imported or uninstalled through the API orhooks.enabledwas written, which is what brought a library install into an open conversation on its next Task. user_prompton every prompt. The engine gained a consult seam,RunOptions.userPrompt(UserPromptFn), whichSession.runwired for the call's first Task. It fired when the run's input carried a user text whosesenderwas absent oruser;server,harnessandparent_agentinputs, stop-hook continuations and steering did not fire it. Hooks ran in package-name order, then manifest order, with{ hook: "user_prompt", session_id, trace_path, scratchpad_dir, prompt }on stdin (trace_pathwas new to this hook point;promptis the user's texts joined by newlines, leading marker blocks stripped) and{ "context": "…" }on stdout.- Where a context goes. Each non-empty context became a user text stamped
sender: "harness": yielded on the stream, written to the Trace right behind the Prompt and ahead of the first run's bootstrap records, and appended to the first request's input. A success left nohookevent. A failure — a non-zero exit, stdout that is not JSON, a timeout or a throw — was recorded at the same position as ahookevent withhook: "user_prompt"and the error as itsreason, and otherwise ignored;HookPayload.hookgained"user_prompt". - Host-triggered commands. A
user_promptcommand took an optionaltrigger:"prompt"(the default) or"host". A host command stayed out of the every-prompt consult and ran only throughSession.runUserPromptHook(name, prompt, extras), which found a package'strigger: "host"hook only, returned null otherwise, and passed the Session's Trace path as well. The zip import route (POST …/hooks/archive) rejected any othertriggervalue. A manifest written before this change is read under a compatibility rule; see backward compatibility. - Hand-written manifests.
hooks.jsonwas read tolerantly (readHookManifest/readHookCommandsin core'sstate/agent-state.ts), because a package is any directory underagent_state/hooks/that carries one: a hook point the manifest leaves out reads as[]; an entry without a stringcommand, or whose command resolves outside the package directory, is dropped, and so are atimeoutthat is not a positive number and an unknowntrigger; a manifest that is not a JSON object makes the directory no hook package; and display fields that are not strings read as absent.GET …/hooksstopped answering 500 for a manifest that lists onlyuser_prompt. - Goal rounds. Core exported
isHookContinue(msg), which recognizes a stop hook'scontinueevent. The server's goal tap (goal_roundevents) and the CLI's goal rendering counted a harness-stamped input as a round only when acontinueevent announced it; round 1 stayed the seeded input on the server and the first hook input in the CLI. Another package's context riding a goal start therefore opened no round. - Plugins.
goalmoved to2026.09.29.1with itsstart.mjsmarkedtrigger: "host".continual-learningmoved to2026.09.29.1: its task window opened at the first record of the input batch — the user's message, its images, and the harness texts right behind it — so the excerpt kept what the user asked.agent-tuningshipped a rewrittenagent-initializationskill that teaches an agent how to create, install and import Skills and hook packages. - Web App and docs. The Hooks tab's chat-import prompt named the optional
trigger, let an unused hook point be left out, and gave theuser_promptstdin withtrace_path. The Agent Loop, Skills & Plugins, Goal Mode, The OmniMessage Protocol, Core Interfaces, Sessions & Traces and Configuration Reference pages described the new contract.
Compatibility
- An in-process
UserPromptHookregistered throughSessionConfig.hooks.userPromptruns on every prompt the user submits, andSession.runUserPromptHookreturns null for a hook that is not markedtrigger: "host". An embedder whose hook belongs to a flow it starts itself addstrigger: "host"to that hook. - A hand-written
hooks.jsonwhoseuser_promptcommand must run only when a host starts it adds"trigger": "host"to the command. - Hook packages installed before this change keep their old reading until they are updated; see backward compatibility. Update the
goalplugin from the plugin library.