mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-28 01:21:36 +00:00
fix(agents): adapt compaction and skill source types
This commit is contained in:
@@ -50,26 +50,13 @@ describe("compaction retry integration", () => {
|
||||
} satisfies AssistantMessage,
|
||||
];
|
||||
|
||||
const testModel: NonNullable<ExtensionContext["model"]> = {
|
||||
id: "claude-3-opus",
|
||||
name: "Claude 3 Opus",
|
||||
api: "anthropic-messages",
|
||||
const testModel = {
|
||||
provider: "anthropic",
|
||||
baseUrl: "https://api.anthropic.com",
|
||||
reasoning: false,
|
||||
input: ["text"],
|
||||
cost: {
|
||||
input: 0,
|
||||
output: 0,
|
||||
cacheRead: 0,
|
||||
cacheWrite: 0,
|
||||
},
|
||||
contextWindow: 200_000,
|
||||
maxTokens: 8_192,
|
||||
};
|
||||
model: "claude-3-opus",
|
||||
} as unknown as NonNullable<ExtensionContext["model"]>;
|
||||
|
||||
const invokeGenerateSummary = (signal = new AbortController().signal) =>
|
||||
mockGenerateSummary(testMessages, testModel, 1000, "test-api-key", undefined, signal);
|
||||
mockGenerateSummary(testMessages, testModel, 1000, "test-api-key", signal);
|
||||
|
||||
const runSummaryRetry = (options: Parameters<typeof retryAsync>[1]) =>
|
||||
retryAsync(() => invokeGenerateSummary(), options);
|
||||
|
||||
@@ -257,7 +257,6 @@ async function summarizeChunks(params: {
|
||||
model,
|
||||
params.reserveTokens,
|
||||
params.apiKey,
|
||||
model.headers,
|
||||
params.signal,
|
||||
effectiveInstructions,
|
||||
summary,
|
||||
|
||||
@@ -614,20 +614,11 @@ export default function compactionSafeguardExtension(api: ExtensionAPI): void {
|
||||
return { cancel: true };
|
||||
}
|
||||
|
||||
const requestAuth = await ctx.modelRegistry.getApiKeyAndHeaders(model);
|
||||
if (!requestAuth.ok) {
|
||||
log.warn(
|
||||
`Compaction safeguard: request auth resolution failed for ${model.provider}/${model.id}: ${requestAuth.error}`,
|
||||
);
|
||||
setCompactionSafeguardCancelReason(
|
||||
ctx.sessionManager,
|
||||
`Compaction safeguard could not resolve request auth for ${model.provider}/${model.id}: ${requestAuth.error}`,
|
||||
);
|
||||
return { cancel: true };
|
||||
}
|
||||
|
||||
const apiKey = requestAuth.apiKey ?? "";
|
||||
const headers = requestAuth.headers ?? model.headers;
|
||||
const headers =
|
||||
model.headers && typeof model.headers === "object" && !Array.isArray(model.headers)
|
||||
? model.headers
|
||||
: undefined;
|
||||
const apiKey = (await ctx.modelRegistry.getApiKey(model)) ?? "";
|
||||
if (!apiKey && !headers) {
|
||||
log.warn(
|
||||
"Compaction safeguard: no request auth available; cancelling compaction to preserve history.",
|
||||
|
||||
@@ -60,13 +60,7 @@ function buildEntry(name: string): SkillEntry {
|
||||
description: `${name} test skill`,
|
||||
filePath: path.join(skillDir, "SKILL.md"),
|
||||
baseDir: skillDir,
|
||||
sourceInfo: {
|
||||
path: path.join(skillDir, "SKILL.md"),
|
||||
source: "openclaw-workspace",
|
||||
scope: "project",
|
||||
origin: "top-level",
|
||||
baseDir: skillDir,
|
||||
},
|
||||
source: "openclaw-workspace",
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
||||
@@ -17,13 +17,7 @@ describe("buildWorkspaceSkillStatus", () => {
|
||||
description: "test",
|
||||
filePath: "/tmp/os-scoped",
|
||||
baseDir: "/tmp",
|
||||
sourceInfo: {
|
||||
path: "/tmp/os-scoped",
|
||||
source: "test",
|
||||
scope: "project",
|
||||
origin: "top-level",
|
||||
baseDir: "/tmp",
|
||||
},
|
||||
source: "test",
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
||||
@@ -24,13 +24,7 @@ function makeEntry(params: {
|
||||
description: `desc:${params.name}`,
|
||||
filePath: `/tmp/${params.name}/SKILL.md`,
|
||||
baseDir: `/tmp/${params.name}`,
|
||||
sourceInfo: {
|
||||
path: `/tmp/${params.name}/SKILL.md`,
|
||||
source: params.source ?? "openclaw-workspace",
|
||||
scope: "project",
|
||||
origin: "top-level",
|
||||
baseDir: `/tmp/${params.name}`,
|
||||
},
|
||||
source: params.source ?? "openclaw-workspace",
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
||||
@@ -17,13 +17,7 @@ describe("resolveSkillsPromptForRun", () => {
|
||||
description: "Demo",
|
||||
filePath: "/app/skills/demo-skill/SKILL.md",
|
||||
baseDir: "/app/skills/demo-skill",
|
||||
sourceInfo: {
|
||||
path: "/app/skills/demo-skill/SKILL.md",
|
||||
source: "openclaw-bundled",
|
||||
scope: "project",
|
||||
origin: "top-level",
|
||||
baseDir: "/app/skills/demo-skill",
|
||||
},
|
||||
source: "openclaw-bundled",
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
||||
@@ -15,13 +15,7 @@ function makeSkill(name: string, desc = "A skill", filePath = `/skills/${name}/S
|
||||
description: desc,
|
||||
filePath,
|
||||
baseDir: `/skills/${name}`,
|
||||
sourceInfo: {
|
||||
path: filePath,
|
||||
source: "workspace",
|
||||
scope: "project",
|
||||
origin: "top-level",
|
||||
baseDir: `/skills/${name}`,
|
||||
},
|
||||
source: "workspace",
|
||||
disableModelInvocation: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Skill } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
export function resolveSkillSource(skill: Skill): string {
|
||||
return skill.sourceInfo.source;
|
||||
return skill.source;
|
||||
}
|
||||
|
||||
@@ -38,13 +38,7 @@ describe("skills-cli (e2e)", () => {
|
||||
description: "Capture UI screenshots",
|
||||
filePath: path.join(baseDir, "SKILL.md"),
|
||||
baseDir,
|
||||
sourceInfo: {
|
||||
path: path.join(baseDir, "SKILL.md"),
|
||||
source: "openclaw-bundled",
|
||||
scope: "project",
|
||||
origin: "top-level",
|
||||
baseDir,
|
||||
},
|
||||
source: "openclaw-bundled",
|
||||
disableModelInvocation: false,
|
||||
},
|
||||
frontmatter: {},
|
||||
|
||||
Reference in New Issue
Block a user