Skip to content

Session-memory hook ignores agent's configured model and uses hardcoded Anthropic default #6794

@jdkohler

Description

@jdkohler

Summary

The session-memory internal hook's LLM slug generator fails when using non-Anthropic model providers (e.g., Kimi, OpenAI, Google) because it doesn't properly pass the agent's configured model to temporary sessions, falling back to hardcoded Anthropic defaults.

Environment

  • OpenClaw version: 2026.1.30
  • Node version: v22.22.0
  • OS: macOS (Darwin 25.2.0)
  • Configured model: kimi-coding/k2p5 (Kimi K2.5)

Steps to Reproduce

  1. Configure openclaw to use a non-Anthropic model provider:
    {
      "agents": {
        "defaults": {
          "model": {
            "primary": "kimi-coding/k2p5"
          }
        }
      }
    }
  2. Enable the session-memory hook:
    {
      "hooks": {
        "internal": {
          "enabled": true,
          "entries": {
            "session-memory": {
              "enabled": true
            }
          }
        }
      }
    }
  3. Run the /new command to trigger session memory saving

Expected Behavior

The session-memory hook should use the agent's configured primary model (kimi-coding/k2p5) to generate LLM-based filename slugs.

Actual Behavior

The hook fails with authentication errors:

[diagnostic] lane task error: lane=session:temp:slug-generator durationMs=12 error="FailoverError: No API key found for provider "anthropic". Auth store: /Users/shelly/.openclaw/agents/main/agent/auth-profiles.json"
[llm-slug-generator] Failed to generate slug: FailoverError: No API key found for provider "anthropic"

The hook falls back to timestamp-based slugs instead of using LLM-generated descriptive names.

Root Cause

1. Hardcoded defaults in /dist/agents/defaults.js:

export const DEFAULT_PROVIDER = "anthropic";
export const DEFAULT_MODEL = "claude-opus-4-5";

2. Missing model parameter in /dist/hooks/llm-slug-generator.js:

The generateSlugViaLLM() function calls runEmbeddedPiAgent() without passing the model parameters:

const result = await runEmbeddedPiAgent({
    sessionId: `slug-generator-${Date.now()}`,
    sessionKey: "temp:slug-generator",
    sessionFile: tempSessionFile,
    workspaceDir,
    agentDir,
    config: params.cfg,  // ← Config is passed but model not extracted
    prompt,
    timeoutMs: 15_000,
    runId: `slug-gen-${Date.now()}`,
});

When no provider and model parameters are provided, runEmbeddedPiAgent() uses the hardcoded DEFAULT_PROVIDER and DEFAULT_MODEL from defaults.js.

Suggested Fix

Modify /dist/hooks/llm-slug-generator.js to extract and pass the configured model:

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

// In generateSlugViaLLM function, before calling runEmbeddedPiAgent:
const primaryModel = params.cfg?.agents?.defaults?.model?.primary;
const parsedModel = primaryModel ? parseModelRef(primaryModel) : null;

const result = await runEmbeddedPiAgent({
    sessionId: `slug-generator-${Date.now()}`,
    sessionKey: "temp:slug-generator",
    sessionFile: tempSessionFile,
    workspaceDir,
    agentDir,
    config: params.cfg,
    provider: parsedModel?.provider,  // ← Add this
    model: parsedModel?.model,        // ← Add this
    prompt,
    timeoutMs: 15_000,
    runId: `slug-gen-${Date.now()}`,
});

Impact

  • Users with non-Anthropic model providers cannot use the session-memory hook's LLM slug generation feature
  • Error messages clutter logs even though the feature gracefully falls back to timestamps
  • Reduces the utility of session memory feature for users not using Anthropic models

Additional Context

This appears to be a broader issue where temporary/embedded sessions don't properly inherit the agent's model configuration. Other features that use runEmbeddedPiAgent() for temporary sessions might have similar issues.

Workaround

Temporarily patch /opt/homebrew/lib/node_modules/openclaw/dist/hooks/llm-slug-generator.js with the suggested fix above, or disable the session-memory hook.

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