mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:50:44 +00:00
context-engine: propagate factory context through subagent-registry
This commit is contained in:
committed by
Josh Lehman
parent
a2fc8b8adf
commit
6b22e5c2d4
@@ -7,6 +7,7 @@ import {
|
||||
type SessionEntry,
|
||||
} from "../config/sessions.js";
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import type { ResolveContextEngineOptions } from "../context-engine/registry.js";
|
||||
import type { ContextEngine, SubagentEndReason } from "../context-engine/types.js";
|
||||
import { callGateway } from "../gateway/call.js";
|
||||
import { getAgentRunContext, onAgentEvent } from "../infra/agent-events.js";
|
||||
@@ -97,7 +98,10 @@ type SubagentRegistryDeps = {
|
||||
runSubagentAnnounceFlow: SubagentAnnounceModule["runSubagentAnnounceFlow"];
|
||||
ensureContextEnginesInitialized?: () => void;
|
||||
ensureRuntimePluginsLoaded?: typeof ensureRuntimePluginsLoadedFn;
|
||||
resolveContextEngine?: (cfg: OpenClawConfig) => Promise<ContextEngine>;
|
||||
resolveContextEngine?: (
|
||||
cfg: OpenClawConfig,
|
||||
options?: ResolveContextEngineOptions,
|
||||
) => Promise<ContextEngine>;
|
||||
};
|
||||
|
||||
let subagentAnnouncePromise: Promise<SubagentAnnounceModule> | null = null;
|
||||
@@ -140,7 +144,10 @@ type ContextEngineInitModule = Pick<
|
||||
>;
|
||||
type ContextEngineRegistryModule = Pick<
|
||||
{
|
||||
resolveContextEngine: (cfg: OpenClawConfig) => Promise<ContextEngine>;
|
||||
resolveContextEngine: (
|
||||
cfg: OpenClawConfig,
|
||||
options?: ResolveContextEngineOptions,
|
||||
) => Promise<ContextEngine>;
|
||||
},
|
||||
"resolveContextEngine"
|
||||
>;
|
||||
@@ -308,7 +315,10 @@ async function ensureSubagentRegistryPluginRuntimeLoaded(params: {
|
||||
(await loadRuntimePluginsModule()).ensureRuntimePluginsLoaded(params);
|
||||
}
|
||||
|
||||
async function resolveSubagentRegistryContextEngine(cfg: OpenClawConfig) {
|
||||
async function resolveSubagentRegistryContextEngine(
|
||||
cfg: OpenClawConfig,
|
||||
options?: ResolveContextEngineOptions,
|
||||
) {
|
||||
const initModule = await loadContextEngineInitModule();
|
||||
const registryModule = await loadContextEngineRegistryModule();
|
||||
const ensureContextEnginesInitialized =
|
||||
@@ -317,7 +327,7 @@ async function resolveSubagentRegistryContextEngine(cfg: OpenClawConfig) {
|
||||
const resolveContextEngine =
|
||||
subagentRegistryDeps.resolveContextEngine ?? registryModule.resolveContextEngine;
|
||||
ensureContextEnginesInitialized();
|
||||
return await resolveContextEngine(cfg);
|
||||
return await resolveContextEngine(cfg, options);
|
||||
}
|
||||
|
||||
function persistSubagentRuns() {
|
||||
@@ -478,7 +488,9 @@ async function notifyContextEngineSubagentEnded(params: {
|
||||
workspaceDir: params.workspaceDir,
|
||||
allowGatewaySubagentBinding: true,
|
||||
});
|
||||
const engine = await resolveSubagentRegistryContextEngine(cfg);
|
||||
const engine = await resolveSubagentRegistryContextEngine(cfg, {
|
||||
workspaceDir: params.workspaceDir,
|
||||
});
|
||||
if (!engine.onSubagentEnded) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user