@@ -77,12 +77,41 @@ function resolveSelectedMemoryPluginIds(params: {
7777 : [ ] ;
7878}
7979
80+ // Every selected model provider must join the immutable run generation before
81+ // request-time hooks resolve; late provider loading is intentionally forbidden.
82+ function resolveSelectedProviderOwnerPluginIds ( params : {
83+ provider : string ;
84+ config ?: OpenClawConfig ;
85+ workspaceDir : string ;
86+ } ) : string [ ] {
87+ const providerOwnerPluginIds = dedupePluginIds (
88+ resolveOwningPluginIdsForProviderRef ( params ) ?? [ ] ,
89+ ) ;
90+ if ( providerOwnerPluginIds . length === 0 ) {
91+ return [ ] ;
92+ }
93+ const safeProviderOwnerPluginIds = dedupePluginIds ( [
94+ ...resolveBundledProviderCompatPluginIds ( {
95+ config : params . config ,
96+ workspaceDir : params . workspaceDir ,
97+ onlyPluginIds : providerOwnerPluginIds ,
98+ } ) ,
99+ ...resolveActivatableProviderOwnerPluginIds ( {
100+ pluginIds : providerOwnerPluginIds ,
101+ config : params . config ,
102+ workspaceDir : params . workspaceDir ,
103+ } ) ,
104+ ] ) ;
105+ return providerOwnerPluginIds . filter ( ( pluginId ) => safeProviderOwnerPluginIds . includes ( pluginId ) ) ;
106+ }
107+
80108/** Resolve manifest owners required by one selected non-core harness runtime. */
81109export function resolveAgentHarnessOwnerPluginIds ( params : {
82110 runtime : string ;
83111 provider : string ;
84112 config ?: OpenClawConfig ;
85113 workspaceDir : string ;
114+ providerOwnerPluginIds ?: readonly string [ ] ;
86115} ) : string [ ] {
87116 const harnessPluginIds = resolveManifestActivationPlan ( {
88117 trigger : { kind : "agentHarness" , runtime : params . runtime } ,
@@ -98,29 +127,14 @@ export function resolveAgentHarnessOwnerPluginIds(params: {
98127 ) {
99128 return harnessPluginIds ;
100129 }
101- const providerOwnerPluginIds = dedupePluginIds (
102- resolveOwningPluginIdsForProviderRef ( params ) ?? [ ] ,
103- ) ;
130+ const providerOwnerPluginIds =
131+ params . providerOwnerPluginIds ?? resolveSelectedProviderOwnerPluginIds ( params ) ;
104132 if ( providerOwnerPluginIds . length === 0 ) {
105133 return harnessPluginIds ;
106134 }
107- const safeProviderOwnerPluginIds = dedupePluginIds ( [
108- ...resolveBundledProviderCompatPluginIds ( {
109- config : params . config ,
110- workspaceDir : params . workspaceDir ,
111- onlyPluginIds : providerOwnerPluginIds ,
112- } ) ,
113- ...resolveActivatableProviderOwnerPluginIds ( {
114- pluginIds : providerOwnerPluginIds ,
115- config : params . config ,
116- workspaceDir : params . workspaceDir ,
117- } ) ,
118- ] ) ;
119135 return dedupePluginIds ( [
120136 ...harnessPluginIds ,
121- ...providerOwnerPluginIds . filter (
122- ( pluginId ) => pluginId !== "codex" && safeProviderOwnerPluginIds . includes ( pluginId ) ,
123- ) ,
137+ ...providerOwnerPluginIds . filter ( ( pluginId ) => pluginId !== "codex" ) ,
124138 ] ) ;
125139}
126140
@@ -157,8 +171,8 @@ export function resolveSelectedAgentHarnessRuntime(
157171 } ) . runtime ;
158172}
159173
160- /** Returns whether a selection needs a plugin-owned harness in its prepared generation. */
161- export function requiresAgentHarnessPluginSelection (
174+ // Returns whether a selection needs a plugin-owned harness in its prepared generation.
175+ function requiresAgentHarnessPluginSelection (
162176 selection : AgentHarnessPluginSelection ,
163177 config ?: OpenClawConfig ,
164178) : boolean {
@@ -195,6 +209,13 @@ export function resolveAgentRuntimePluginLoadPlan(params: {
195209 const forceActivatedPluginIds = [ ...memoryPluginIds , ...contextEnginePluginIds ] ;
196210 for ( const selection of params . selections ) {
197211 const runtime = resolveSelectedAgentHarnessRuntime ( selection , config ) ;
212+ const providerOwnerPluginIds = resolveSelectedProviderOwnerPluginIds ( {
213+ provider : selection . provider ,
214+ config,
215+ workspaceDir : params . workspaceDir ,
216+ } ) ;
217+ pluginIds . push ( ...providerOwnerPluginIds ) ;
218+ forceActivatedPluginIds . push ( ...providerOwnerPluginIds ) ;
198219 if ( ! requiresAgentHarnessPluginSelection ( selection , config ) ) {
199220 continue ;
200221 }
@@ -203,6 +224,7 @@ export function resolveAgentRuntimePluginLoadPlan(params: {
203224 provider : selection . provider ,
204225 config,
205226 workspaceDir : params . workspaceDir ,
227+ providerOwnerPluginIds,
206228 } ) ;
207229 pluginIds . push ( ...harnessPluginIds ) ;
208230 const allowedHarnessPluginIds =
0 commit comments