Repository navigation
hooks: prompt hook for /review and /run; pre_compact before automatic compaction (refs #26) - #37
Merged
Merged
Conversation
…efs #26) /review sent its prompt with no hook run, and /run's workers took each task's instruction straight from the ledger, so the operator's prompt check covered typed lines and -t only. /review now runs it on the review prompt (review_turn); /run runs it in run_memory::Remembered, the one wrapper every worker and lane goes through, on each task's instruction. A refusal sends nothing; the hook's output rides that turn, carried to the agent by the new TaskWorker::operator_context.
Automatic compaction runs inside ApiBackend::compact_if_near_window, which fired nothing, so the operator's pre_compact covered /compact only. The backend's toolbox already holds the operator's hooks, the pinned session and the workspace; Toolbox::operator_pre_compact runs them with trigger auto before the summary is asked for. What they print travels as the new AgentEvent::Notice, shown by the REPL (a line of its own, also in the follow-up pass), --acp (a thought, once: the REPL arm stands aside for an observer) and -t; Thinking, which the REPL does not show, would have hidden it.
This was referenced Oct 22, 2026
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.
The last two hook gaps from #26 item 5.
user_prompt_submitfor/reviewand/runBefore this, the operator's prompt check covered typed lines and
-tonly./reviewnow runs the hook on the review prompt it builds, diff included, so a secret scanner sees what will be sent. This iscli::review_turn, which the REPL's/reviewcalls. A refusal sends nothing; the hook's output rides the turn./runnow runs it on each task's instruction, before the worker or the memory engine hears it. This happens inrun_memory::Remembered, the one wrapper every/runworker and lane goes through, in the REPL and over--acp.TaskWorker::operator_context.AgentBackendWorkerappends it right after the task's instruction.from_settingsgoes through the plugin allowlist.pre_compactbefore automatic compactionThe API route compacts on its own near the context window (
ApiBackend::compact_if_near_window), and that fired nothing.Toolbox::operator_pre_compactrunspre_compactwithtrigger: "auto"before the summary is asked for./compactis unchanged (trigger: "manual"), and nothing fires twice.AgentEvent::Noticecarries what the hooks print.Thinkingwould have hidden it, because the REPL does not showThinking. Where it appears:--acp: a thought chunk, shown once. The REPL arm stands aside when an observer presents it.-t: a·line, or{"type":"notice"}in stream-json.wiring.rs's note onrun_on_compactno longer says the API backend holds no hooks.Tests (each with a control that puts the bug back)
/review:cli::agent_turn::tests::a_review_refused_by_the_operators_hook_reaches_no_agent, on a real git repo. Exit 2 means no prompt; exit 0 means the prompt carries the diff and the hook's output./run:cli::run_memory::tests::a_task_refused_by_the_prompt_hook_is_not_worked_and_an_allowed_one_carries_its_context.agent::worker::tests::the_operators_hook_context_reaches_the_agents_prompt_after_the_task.agent::api::tests::the_operators_pre_compact_hook_runs_before_an_automatic_compaction. The hook echoes its stdin; its notice carries"trigger":"auto"and comes before the compaction's own note.cli::agent_turn::tests::a_notice_mid_turn_is_shown_on_its_own_line.--acpnotice:acp_agent::workers::tests::a_notice_becomes_a_thought_chunk_for_the_session_and_a_workeracp_agent::worker_tests::a_notice_arrives_as_a_thought_chunk_not_as_the_reply. This test caught the notice being sent twice over--acp, as a thought and as reply text, before the observer fix.Local Windows gate: fmt, clippy
-D warnings,cargo test(2210 lib + 59 bin).Not covered
Thinking, which the REPL does not show. That predates this change and is left as is.