Skip to content

hackbot: run per-action-type hooks before recording an action - #6425

Merged
suhaibmujahid merged 1 commit into
mozilla:masterfrom
suhaibmujahid:worktree-action-hooks
Jul 30, 2026
Merged

hackbot: run per-action-type hooks before recording an action#6425
suhaibmujahid merged 1 commit into
mozilla:masterfrom
suhaibmujahid:worktree-action-hooks

Conversation

@suhaibmujahid

Copy link
Copy Markdown
Member

Resolves #6424

ActionsRecorder now takes a mapping of action type to hooks (plus add_hook for wiring one after construction). Each hook receives the fully built action dict just before it is appended and may mutate it in place; raising aborts the recording, so a hook also serves as a validation gate.

Hooks live on the recorder so the runtime can attach behaviour that cuts across action domains without every handler knowing about it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds per-action-type “pre-record” hooks to hackbot_runtime.actions.ActionsRecorder, allowing the runtime to enrich or reject actions centrally right before they’re appended to the recorder.

Changes:

  • Introduces an ActionHook type and hook registration (hooks= in constructor + add_hook()).
  • Executes registered hooks in order during record() and propagates hook exceptions to abort recording.
  • Adds unit tests covering ordering, scoping, mutation visibility, abort behavior, and hook registration semantics.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
libs/hackbot-runtime/hackbot_runtime/actions/recorder.py Adds hook storage/registration and runs hooks during record() before appending actions.
libs/hackbot-runtime/hackbot_runtime/actions/init.py Exports ActionHook alongside ActionsRecorder.
libs/hackbot-runtime/tests/test_recorder.py Adds test coverage for the new hook behavior and invariants.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libs/hackbot-runtime/hackbot_runtime/actions/recorder.py Outdated
@suhaibmujahid
suhaibmujahid force-pushed the worktree-action-hooks branch 2 times, most recently from 3dec664 to c07fded Compare July 30, 2026 00:47
@suhaibmujahid
suhaibmujahid force-pushed the worktree-action-hooks branch from c07fded to 944a526 Compare July 30, 2026 02:31
@suhaibmujahid
suhaibmujahid enabled auto-merge (squash) July 30, 2026 18:47
@suhaibmujahid
suhaibmujahid merged commit 03bf6fe into mozilla:master Jul 30, 2026
7 checks passed
@suhaibmujahid
suhaibmujahid deleted the worktree-action-hooks branch July 30, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support running hooks in Hackbot agents before an action is recorded

3 participants