Commit bcd6e4a
perf(agents/runtime): short-circuit ensureRuntimePluginsLoaded when active registry exists
ensureRuntimePluginsLoaded is called from dispatchReplyFromConfig on
every inbound message and was rebuilding the entire plugin registry
on each call.
Root cause: it builds a 3-field options object (config, workspaceDir,
runtimeOptions) and calls resolveRuntimePluginRegistry. That ends up
in getCompatibleActivePluginRegistry, which does a strict cacheKey
equality check against the active registry's cache key. The boot path
(loadGatewayPlugins) populates the active registry with a 9+ field
options set (onlyPluginIds, activationSourceConfig, autoEnabledReasons,
coreGatewayHandlers, ...). The dispatch-time hash and the boot-time
hash always differ, the equality check always fails, and the dispatcher
falls through to a full loadOpenClawPlugins — re-importing every
plugin module, re-validating manifests, and re-running each plugin's
register(). On hosted gateways with plugins.entries populated, that's
~5–6s of wasted wall-clock per inbound message even when the active
registry was already a valid answer.
The function exists to *ensure* runtime plugins are loaded — if the
active registry is already populated, the goal is already met.
Plugin reconfiguration (installs / uninstalls / auto-enable changes)
already invalidates the active registry through other code paths
(setActivePluginRegistry, gateway restart on config write), so a stale
active registry is not a concern here.
Updates the existing "does not reactivate plugins when a process
already has an active registry" test (which was asserting one call —
incorrect; the prior code reactivated every time) into a regression
test that asserts zero calls when getActivePluginRegistry returns
truthy.
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent 3cad579 commit bcd6e4a
2 files changed
Lines changed: 39 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| 26 | + | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
30 | | - | |
31 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
32 | 43 | | |
33 | 44 | | |
34 | 45 | | |
35 | 46 | | |
36 | 47 | | |
37 | 48 | | |
38 | 49 | | |
39 | | - | |
| 50 | + | |
40 | 51 | | |
41 | 52 | | |
42 | | - | |
| 53 | + | |
43 | 54 | | |
44 | 55 | | |
45 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
11 | 34 | | |
12 | 35 | | |
13 | 36 | | |
| |||
0 commit comments