fix: respect agent model config in slug generator (#24776)

The slug generator was using hardcoded DEFAULT_PROVIDER and DEFAULT_MODEL
instead of resolving from agent config. This caused it to fall back to
anthropic/claude-opus-4-6 even when a cloud model was configured.

Now uses resolveAgentModelPrimary() to get the configured model, with
fallback to defaults if not configured.

Fixes issue where session memory filenames would fail to generate
when using cloud models that require special backends.
This commit is contained in:
Bill Cropper
2026-02-23 22:22:48 -05:00
committed by GitHub
parent e2e10b3da4
commit 588ad7fb38

View File

@@ -9,7 +9,10 @@ import {
resolveDefaultAgentId,
resolveAgentWorkspaceDir,
resolveAgentDir,
resolveAgentModelPrimary,
} from "../agents/agent-scope.js";
import { DEFAULT_PROVIDER, DEFAULT_MODEL } from "../agents/defaults.js";
import { parseModelRef } from "../agents/model-selection.js";
import { runEmbeddedPiAgent } from "../agents/pi-embedded.js";
import type { OpenClawConfig } from "../config/config.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
@@ -41,6 +44,12 @@ ${params.sessionContent.slice(0, 2000)}
Reply with ONLY the slug, nothing else. Examples: "vendor-pitch", "api-design", "bug-fix"`;
// Resolve model from agent config instead of using hardcoded defaults
const modelRef = resolveAgentModelPrimary(params.cfg, agentId);
const parsed = modelRef ? parseModelRef(modelRef, DEFAULT_PROVIDER) : null;
const provider = parsed?.provider ?? DEFAULT_PROVIDER;
const model = parsed?.model ?? DEFAULT_MODEL;
const result = await runEmbeddedPiAgent({
sessionId: `slug-generator-${Date.now()}`,
sessionKey: "temp:slug-generator",
@@ -50,6 +59,8 @@ Reply with ONLY the slug, nothing else. Examples: "vendor-pitch", "api-design",
agentDir,
config: params.cfg,
prompt,
provider,
model,
timeoutMs: 15_000, // 15 second timeout
runId: `slug-gen-${Date.now()}`,
});