mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 20:40:43 +00:00
agents: propagate config for embedded skill loading
This commit is contained in:
@@ -11,6 +11,7 @@ Docs: https://docs.openclaw.ai
|
|||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|
||||||
|
- Agents/Skills runtime loading: propagate run config into embedded attempt and compaction skill-entry loading so explicitly enabled bundled companion skills are discovered consistently when skill snapshots do not already provide resolved entries. Thanks @gumadeiras.
|
||||||
- Agents/Compaction continuity: expand staged-summary merge instructions to preserve active task status, batch progress, latest user request, and follow-up commitments so compaction handoffs retain in-flight work context. (#8903) thanks @joetomasone.
|
- Agents/Compaction continuity: expand staged-summary merge instructions to preserve active task status, batch progress, latest user request, and follow-up commitments so compaction handoffs retain in-flight work context. (#8903) thanks @joetomasone.
|
||||||
- Gateway/status self version reporting: make Gateway self version in `openclaw status` prefer runtime `VERSION` (while preserving explicit `OPENCLAW_VERSION` override), preventing stale post-upgrade app version output. (#32655) thanks @liuxiaopai-ai.
|
- Gateway/status self version reporting: make Gateway self version in `openclaw status` prefer runtime `VERSION` (while preserving explicit `OPENCLAW_VERSION` override), preventing stale post-upgrade app version output. (#32655) thanks @liuxiaopai-ai.
|
||||||
- Memory/QMD index isolation: set `QMD_CONFIG_DIR` alongside `XDG_CONFIG_HOME` so QMD config state stays per-agent despite upstream XDG handling bugs, preventing cross-agent collection indexing and excess disk/CPU usage. (#27028) thanks @HenryLoenwind.
|
- Memory/QMD index isolation: set `QMD_CONFIG_DIR` alongside `XDG_CONFIG_HOME` so QMD config state stays per-agent despite upstream XDG handling bugs, preventing cross-agent collection indexing and excess disk/CPU usage. (#27028) thanks @HenryLoenwind.
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ import { detectRuntimeShell } from "../shell-utils.js";
|
|||||||
import {
|
import {
|
||||||
applySkillEnvOverrides,
|
applySkillEnvOverrides,
|
||||||
applySkillEnvOverridesFromSnapshot,
|
applySkillEnvOverridesFromSnapshot,
|
||||||
loadWorkspaceSkillEntries,
|
|
||||||
resolveSkillsPromptForRun,
|
resolveSkillsPromptForRun,
|
||||||
type SkillSnapshot,
|
type SkillSnapshot,
|
||||||
} from "../skills.js";
|
} from "../skills.js";
|
||||||
@@ -74,6 +73,7 @@ import { log } from "./logger.js";
|
|||||||
import { buildModelAliasLines, resolveModel } from "./model.js";
|
import { buildModelAliasLines, resolveModel } from "./model.js";
|
||||||
import { buildEmbeddedSandboxInfo } from "./sandbox-info.js";
|
import { buildEmbeddedSandboxInfo } from "./sandbox-info.js";
|
||||||
import { prewarmSessionFile, trackSessionManagerAccess } from "./session-manager-cache.js";
|
import { prewarmSessionFile, trackSessionManagerAccess } from "./session-manager-cache.js";
|
||||||
|
import { resolveEmbeddedRunSkillEntries } from "./skills-runtime.js";
|
||||||
import {
|
import {
|
||||||
applySystemPromptOverrideToSession,
|
applySystemPromptOverrideToSession,
|
||||||
buildEmbeddedSystemPrompt,
|
buildEmbeddedSystemPrompt,
|
||||||
@@ -333,10 +333,11 @@ export async function compactEmbeddedPiSessionDirect(
|
|||||||
let restoreSkillEnv: (() => void) | undefined;
|
let restoreSkillEnv: (() => void) | undefined;
|
||||||
process.chdir(effectiveWorkspace);
|
process.chdir(effectiveWorkspace);
|
||||||
try {
|
try {
|
||||||
const shouldLoadSkillEntries = !params.skillsSnapshot || !params.skillsSnapshot.resolvedSkills;
|
const { shouldLoadSkillEntries, skillEntries } = resolveEmbeddedRunSkillEntries({
|
||||||
const skillEntries = shouldLoadSkillEntries
|
workspaceDir: effectiveWorkspace,
|
||||||
? loadWorkspaceSkillEntries(effectiveWorkspace)
|
config: params.config,
|
||||||
: [];
|
skillsSnapshot: params.skillsSnapshot,
|
||||||
|
});
|
||||||
restoreSkillEnv = params.skillsSnapshot
|
restoreSkillEnv = params.skillsSnapshot
|
||||||
? applySkillEnvOverridesFromSnapshot({
|
? applySkillEnvOverridesFromSnapshot({
|
||||||
snapshot: params.skillsSnapshot,
|
snapshot: params.skillsSnapshot,
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ import { detectRuntimeShell } from "../../shell-utils.js";
|
|||||||
import {
|
import {
|
||||||
applySkillEnvOverrides,
|
applySkillEnvOverrides,
|
||||||
applySkillEnvOverridesFromSnapshot,
|
applySkillEnvOverridesFromSnapshot,
|
||||||
loadWorkspaceSkillEntries,
|
|
||||||
resolveSkillsPromptForRun,
|
resolveSkillsPromptForRun,
|
||||||
} from "../../skills.js";
|
} from "../../skills.js";
|
||||||
import { buildSystemPromptParams } from "../../system-prompt-params.js";
|
import { buildSystemPromptParams } from "../../system-prompt-params.js";
|
||||||
@@ -99,6 +98,7 @@ import {
|
|||||||
import { buildEmbeddedSandboxInfo } from "../sandbox-info.js";
|
import { buildEmbeddedSandboxInfo } from "../sandbox-info.js";
|
||||||
import { prewarmSessionFile, trackSessionManagerAccess } from "../session-manager-cache.js";
|
import { prewarmSessionFile, trackSessionManagerAccess } from "../session-manager-cache.js";
|
||||||
import { prepareSessionManagerForRun } from "../session-manager-init.js";
|
import { prepareSessionManagerForRun } from "../session-manager-init.js";
|
||||||
|
import { resolveEmbeddedRunSkillEntries } from "../skills-runtime.js";
|
||||||
import {
|
import {
|
||||||
applySystemPromptOverrideToSession,
|
applySystemPromptOverrideToSession,
|
||||||
buildEmbeddedSystemPrompt,
|
buildEmbeddedSystemPrompt,
|
||||||
@@ -570,10 +570,11 @@ export async function runEmbeddedAttempt(
|
|||||||
let restoreSkillEnv: (() => void) | undefined;
|
let restoreSkillEnv: (() => void) | undefined;
|
||||||
process.chdir(effectiveWorkspace);
|
process.chdir(effectiveWorkspace);
|
||||||
try {
|
try {
|
||||||
const shouldLoadSkillEntries = !params.skillsSnapshot || !params.skillsSnapshot.resolvedSkills;
|
const { shouldLoadSkillEntries, skillEntries } = resolveEmbeddedRunSkillEntries({
|
||||||
const skillEntries = shouldLoadSkillEntries
|
workspaceDir: effectiveWorkspace,
|
||||||
? loadWorkspaceSkillEntries(effectiveWorkspace)
|
config: params.config,
|
||||||
: [];
|
skillsSnapshot: params.skillsSnapshot,
|
||||||
|
});
|
||||||
restoreSkillEnv = params.skillsSnapshot
|
restoreSkillEnv = params.skillsSnapshot
|
||||||
? applySkillEnvOverridesFromSnapshot({
|
? applySkillEnvOverridesFromSnapshot({
|
||||||
snapshot: params.skillsSnapshot,
|
snapshot: params.skillsSnapshot,
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
import fs from "node:fs/promises";
|
||||||
|
import os from "node:os";
|
||||||
|
import path from "node:path";
|
||||||
|
import { afterEach, describe, expect, it } from "vitest";
|
||||||
|
import type { OpenClawConfig } from "../../config/config.js";
|
||||||
|
import { clearPluginManifestRegistryCache } from "../../plugins/manifest-registry.js";
|
||||||
|
import { resolveEmbeddedRunSkillEntries } from "./skills-runtime.js";
|
||||||
|
|
||||||
|
const tempDirs: string[] = [];
|
||||||
|
const originalBundledDir = process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
|
||||||
|
|
||||||
|
async function createTempDir(prefix: string) {
|
||||||
|
const dir = await fs.mkdtemp(path.join(os.tmpdir(), prefix));
|
||||||
|
tempDirs.push(dir);
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setupBundledDiffsPlugin() {
|
||||||
|
const bundledPluginsDir = await createTempDir("openclaw-bundled-");
|
||||||
|
const workspaceDir = await createTempDir("openclaw-workspace-");
|
||||||
|
const pluginRoot = path.join(bundledPluginsDir, "diffs");
|
||||||
|
|
||||||
|
await fs.mkdir(path.join(pluginRoot, "skills", "diffs"), { recursive: true });
|
||||||
|
await fs.writeFile(
|
||||||
|
path.join(pluginRoot, "openclaw.plugin.json"),
|
||||||
|
JSON.stringify(
|
||||||
|
{
|
||||||
|
id: "diffs",
|
||||||
|
skills: ["./skills"],
|
||||||
|
configSchema: { type: "object", additionalProperties: false, properties: {} },
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
2,
|
||||||
|
),
|
||||||
|
"utf-8",
|
||||||
|
);
|
||||||
|
await fs.writeFile(path.join(pluginRoot, "index.ts"), "export {};\n", "utf-8");
|
||||||
|
await fs.writeFile(
|
||||||
|
path.join(pluginRoot, "skills", "diffs", "SKILL.md"),
|
||||||
|
`---\nname: diffs\ndescription: runtime integration test\n---\n`,
|
||||||
|
"utf-8",
|
||||||
|
);
|
||||||
|
|
||||||
|
return { bundledPluginsDir, workspaceDir };
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = originalBundledDir;
|
||||||
|
clearPluginManifestRegistryCache();
|
||||||
|
await Promise.all(
|
||||||
|
tempDirs.splice(0, tempDirs.length).map((dir) => fs.rm(dir, { recursive: true, force: true })),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("resolveEmbeddedRunSkillEntries (integration)", () => {
|
||||||
|
it("loads bundled diffs skill when explicitly enabled in config", async () => {
|
||||||
|
const { bundledPluginsDir, workspaceDir } = await setupBundledDiffsPlugin();
|
||||||
|
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = bundledPluginsDir;
|
||||||
|
clearPluginManifestRegistryCache();
|
||||||
|
|
||||||
|
const config: OpenClawConfig = {
|
||||||
|
plugins: {
|
||||||
|
entries: {
|
||||||
|
diffs: { enabled: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = resolveEmbeddedRunSkillEntries({
|
||||||
|
workspaceDir,
|
||||||
|
config,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.shouldLoadSkillEntries).toBe(true);
|
||||||
|
expect(result.skillEntries.map((entry) => entry.skill.name)).toContain("diffs");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("skips bundled diffs skill when config is missing", async () => {
|
||||||
|
const { bundledPluginsDir, workspaceDir } = await setupBundledDiffsPlugin();
|
||||||
|
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = bundledPluginsDir;
|
||||||
|
clearPluginManifestRegistryCache();
|
||||||
|
|
||||||
|
const result = resolveEmbeddedRunSkillEntries({
|
||||||
|
workspaceDir,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.shouldLoadSkillEntries).toBe(true);
|
||||||
|
expect(result.skillEntries.map((entry) => entry.skill.name)).not.toContain("diffs");
|
||||||
|
});
|
||||||
|
});
|
||||||
67
src/agents/pi-embedded-runner/skills-runtime.test.ts
Normal file
67
src/agents/pi-embedded-runner/skills-runtime.test.ts
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
import type { OpenClawConfig } from "../../config/config.js";
|
||||||
|
import type { SkillSnapshot } from "../skills.js";
|
||||||
|
|
||||||
|
const hoisted = vi.hoisted(() => ({
|
||||||
|
loadWorkspaceSkillEntries: vi.fn(() => []),
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock("../skills.js", async (importOriginal) => {
|
||||||
|
const actual = await importOriginal<typeof import("../skills.js")>();
|
||||||
|
return {
|
||||||
|
...actual,
|
||||||
|
loadWorkspaceSkillEntries: (...args: unknown[]) => hoisted.loadWorkspaceSkillEntries(...args),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const { resolveEmbeddedRunSkillEntries } = await import("./skills-runtime.js");
|
||||||
|
|
||||||
|
describe("resolveEmbeddedRunSkillEntries", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
hoisted.loadWorkspaceSkillEntries.mockReset();
|
||||||
|
hoisted.loadWorkspaceSkillEntries.mockReturnValue([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("loads skill entries with config when no resolved snapshot skills exist", () => {
|
||||||
|
const config: OpenClawConfig = {
|
||||||
|
plugins: {
|
||||||
|
entries: {
|
||||||
|
diffs: { enabled: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = resolveEmbeddedRunSkillEntries({
|
||||||
|
workspaceDir: "/tmp/workspace",
|
||||||
|
config,
|
||||||
|
skillsSnapshot: {
|
||||||
|
prompt: "skills prompt",
|
||||||
|
skills: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.shouldLoadSkillEntries).toBe(true);
|
||||||
|
expect(hoisted.loadWorkspaceSkillEntries).toHaveBeenCalledTimes(1);
|
||||||
|
expect(hoisted.loadWorkspaceSkillEntries).toHaveBeenCalledWith("/tmp/workspace", { config });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("skips skill entry loading when resolved snapshot skills are present", () => {
|
||||||
|
const snapshot: SkillSnapshot = {
|
||||||
|
prompt: "skills prompt",
|
||||||
|
skills: [{ name: "diffs" }],
|
||||||
|
resolvedSkills: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = resolveEmbeddedRunSkillEntries({
|
||||||
|
workspaceDir: "/tmp/workspace",
|
||||||
|
config: {},
|
||||||
|
skillsSnapshot: snapshot,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toEqual({
|
||||||
|
shouldLoadSkillEntries: false,
|
||||||
|
skillEntries: [],
|
||||||
|
});
|
||||||
|
expect(hoisted.loadWorkspaceSkillEntries).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
19
src/agents/pi-embedded-runner/skills-runtime.ts
Normal file
19
src/agents/pi-embedded-runner/skills-runtime.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import type { OpenClawConfig } from "../../config/config.js";
|
||||||
|
import { loadWorkspaceSkillEntries, type SkillEntry, type SkillSnapshot } from "../skills.js";
|
||||||
|
|
||||||
|
export function resolveEmbeddedRunSkillEntries(params: {
|
||||||
|
workspaceDir: string;
|
||||||
|
config?: OpenClawConfig;
|
||||||
|
skillsSnapshot?: SkillSnapshot;
|
||||||
|
}): {
|
||||||
|
shouldLoadSkillEntries: boolean;
|
||||||
|
skillEntries: SkillEntry[];
|
||||||
|
} {
|
||||||
|
const shouldLoadSkillEntries = !params.skillsSnapshot || !params.skillsSnapshot.resolvedSkills;
|
||||||
|
return {
|
||||||
|
shouldLoadSkillEntries,
|
||||||
|
skillEntries: shouldLoadSkillEntries
|
||||||
|
? loadWorkspaceSkillEntries(params.workspaceDir, { config: params.config })
|
||||||
|
: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user