mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 17:51:24 +00:00
fix(auto-reply): preserve OpenRouter @preset model directives (#23769)
* Auto-reply: preserve OpenRouter @preset model directives * Changelog: move OpenRouter preset fix into 2026.2.22 unreleased
This commit is contained in:
@@ -36,6 +36,20 @@ describe("extractModelDirective", () => {
|
||||
expect(result.rawProfile).toBe("myprofile");
|
||||
});
|
||||
|
||||
it("keeps OpenRouter preset paths that include @ in the model name", () => {
|
||||
const result = extractModelDirective("/model openrouter/@preset/kimi-2-5");
|
||||
expect(result.hasDirective).toBe(true);
|
||||
expect(result.rawModel).toBe("openrouter/@preset/kimi-2-5");
|
||||
expect(result.rawProfile).toBeUndefined();
|
||||
});
|
||||
|
||||
it("still allows profile overrides after OpenRouter preset paths", () => {
|
||||
const result = extractModelDirective("/model openrouter/@preset/kimi-2-5@work");
|
||||
expect(result.hasDirective).toBe(true);
|
||||
expect(result.rawModel).toBe("openrouter/@preset/kimi-2-5");
|
||||
expect(result.rawProfile).toBe("work");
|
||||
});
|
||||
|
||||
it("returns no directive for plain text", () => {
|
||||
const result = extractModelDirective("hello world");
|
||||
expect(result.hasDirective).toBe(false);
|
||||
|
||||
@@ -33,10 +33,16 @@ export function extractModelDirective(
|
||||
|
||||
let rawModel = raw;
|
||||
let rawProfile: string | undefined;
|
||||
if (raw?.includes("@")) {
|
||||
const parts = raw.split("@");
|
||||
rawModel = parts[0]?.trim();
|
||||
rawProfile = parts.slice(1).join("@").trim() || undefined;
|
||||
if (raw) {
|
||||
const atIndex = raw.lastIndexOf("@");
|
||||
if (atIndex > 0) {
|
||||
const candidateModel = raw.slice(0, atIndex).trim();
|
||||
const candidateProfile = raw.slice(atIndex + 1).trim();
|
||||
if (candidateModel && candidateProfile && !candidateProfile.includes("/")) {
|
||||
rawModel = candidateModel;
|
||||
rawProfile = candidateProfile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const cleaned = match ? body.replace(match[0], " ").replace(/\s+/g, " ").trim() : body.trim();
|
||||
|
||||
Reference in New Issue
Block a user