Skip to content

session-memory hook uses hardcoded Claude model instead of user's default model #6796

@gulubao

Description

@gulubao

Bug Description

The session-memory hook (which saves session context when /new command is triggered) uses a hardcoded Anthropic Claude model for generating the session slug, instead of respecting the user's configured default model.

Root Cause

In dist/hooks/llm-slug-generator.js, the generateSlugViaLLM() function calls runEmbeddedPiAgent() without specifying the provider and model parameters:

const result = await runEmbeddedPiAgent({
    sessionId: `slug-generator-${Date.now()}`,
    // ... other params
    // provider is NOT specified
    // model is NOT specified
});

When these parameters are missing, pi-embedded-runner/run.js falls back to hardcoded defaults:

const provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER; // "anthropic"
const modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL; // "claude-opus-4-5"

Error Impact

Users who have configured a non-Anthropic default model (e.g., Kimi, GLM, etc.) but don't have an Anthropic API key will see this error when running /new:

FailoverError: No API key found for provider "anthropic".

This causes the session slug generation to fail, falling back to a timestamp-based slug instead of a descriptive one.

Proposed Fix

Modify dist/hooks/llm-slug-generator.js to resolve and use the user's configured default model:

import { resolveDefaultModelForAgent } from "../agents/model-selection.js";

export async function generateSlugViaLLM(params) {
    // ...
    const agentId = resolveDefaultAgentId(params.cfg);
    
    // Resolve the user's configured default model
    const defaultModel = resolveDefaultModelForAgent({ cfg: params.cfg, agentId });
    
    const result = await runEmbeddedPiAgent({
        // ...
        provider: defaultModel.provider,  // Use configured provider
        model: defaultModel.model,        // Use configured model
        // ...
    });
    // ...
}

Environment

  • OpenClaw version: 2026.1.30
  • Configured default model: kimi-coding/k2p5
  • Error: FailoverError: No API key found for provider "anthropic"

Workaround

Until this is fixed, users can either:

  1. Disable the session-memory hook: openclaw hooks disable session-memory
  2. Configure an Anthropic API key: openclaw agents add anthropic

Thanks for the great work on OpenClaw! 🦞

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions