Skip to content

[Brook] Added a plugin hook at the end of each Workflow Activation. - #325

Closed
moetemp wants to merge 3 commits into
moe/brook/v3/p2-extension-callfrom
moe/brook/v3/p3-activation-hook
Closed

moetemp wants to merge 3 commits into
moe/brook/v3/p2-extension-callfrom
moe/brook/v3/p3-activation-hook

Conversation

@moetemp

@moetemp moetemp commented Oct 21, 2026

Copy link
Copy Markdown
Owner

What changed?

This PR adds Plugin.on_workflow_activation_complete(input) and workflow.send_to_plugins(value, during_replay=False). Workflow code, or a plugin's Workflow interceptor, gives values to send_to_plugins. After each successful Activation, the Worker encodes the completion, then calls the hook outside the sandbox with that Activation's values and the Workflow's data converter, then completes the Activation. An exception from the hook fails the Workflow Task. A value given during replay is dropped unless during_replay=True. The Replayer never calls the hook.

Why?

Workflow code runs in the sandbox, so it can't run the payload codec or call native code. A plugin needs a point after the Activation and before Core gets the completion. TypeScript has this as a sink with callDuringReplay.

How did you test it?

pytest tests/worker/test_activation_complete_hook.py. It covers the sandboxed and the unsandboxed runner, a cache miss replay, a hook that fails the task, and the Replayer.

  • Unit Tests
  • Staging
  • End to End Tests

Workflow code runs in the sandbox, so it can't run the payload codec or call native code. Workflow code gives values to send_to_plugins, and the Worker passes them to the plugin hook outside the sandbox before it completes the Activation. Values from replay are dropped unless the caller asks for them.
A cancel from the hook skipped the completion, so the Activation never completed.
@moetemp

moetemp commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

Closing as stale. This layer is folded into the v5 tip, #365, and the upstream review uses a fresh series instead. Plan: https://www.notion.so/4048fc567738814990b7c796ac28fe3f

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.

1 participant