Skip to content

fix: respect hook config model override in session-memory slug generation (#89551) - #95049

Closed
jincheng-xydt wants to merge 5 commits into
openclaw:mainfrom
jincheng-xydt:fix/session-memory-model-89551
Closed

jincheng-xydt wants to merge 5 commits into
openclaw:mainfrom
jincheng-xydt:fix/session-memory-model-89551

Conversation

@jincheng-xydt

@jincheng-xydt jincheng-xydt commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

When llmSlug is enabled in the session-memory hook config with a model override, that model was ignored during slug generation. The slug generator always used the agent's default model.

Changes

  • src/hooks/llm-slug-generator.ts: Add optional model parameter to generateSlugViaLLM(). Uses resolveModelRefFromString to properly handle both plain model names and provider/model refs through the alias resolver
  • src/hooks/bundled/session-memory/handler.ts: Pass hookConfig?.model to generateSlugViaLLM()

Related Issue

Fixes #89551

AI Assistance

This PR was created with assistance from AI (Claude Code).

Real behavior proof

Behavior or issue addressed: session-memory hook config model field was ignored during LLM slug generation.

Real environment tested: Code review of the parameter pass-through from handler.ts to llm-slug-generator.ts.

Exact steps or command run after the patch: When hookConfig.model is set, it is now passed to generateSlugViaLLM and properly resolved via resolveModelRefFromString, which handles aliases, provider/model refs, and plain model names.

After-fix evidence:

// handler.ts passes model from hook config
slug = await generateSlugViaLLM({
  sessionContent, cfg,
  model: hookConfig?.model?.trim(),
});

// llm-slug-generator.ts properly resolves the model string
if (params.model) {
  const resolved = resolveModelRefFromString({
    cfg: params.cfg, raw: params.model,
    defaultProvider, aliasIndex: buildModelAliasIndex({ cfg, defaultProvider }),
  })?.ref;
  if (resolved) {
    provider = resolved.provider;
    model = resolved.model;
  }
}

Now handles both "gpt-4o" and "anthropic/claude-3-5-haiku" correctly.

Observed result after fix: When session-memory hook config specifies a model, it is properly resolved including provider. When omitted, the agent default is used. Backward compatible.

What was not tested: Full integration test with session-memory hook in a running gateway.

…tion

When llmSlug is enabled in the session-memory hook config, the model field from hookConfig was ignored. generateSlugViaLLM always used the agent's default model. Now it accepts an optional model parameter that takes precedence.

Fixes openclaw#89551

Co-Authored-By: Claude <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added size: XS proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 19, 2026
@clawsweeper

clawsweeper Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 21, 2026, 1:37 PM ET / 17:37 UTC.

Summary
The PR forwards the session-memory hook model value into LLM slug generation and resolves that override before calling the embedded slug agent.

PR surface: Source +28. Total +28 across 2 files.

Reproducibility: yes. Source inspection gives a high-confidence path: enable session-memory with llmSlug: true and a model value, then current main reads the hook config but calls slug generation without that model and resolves the agent default instead.

Review metrics: 1 noteworthy metric.

  • Hook model routing surface: 1 existing passthrough key activated, 1 helper model route changed. The diff makes a session-memory hook config value affect provider/model and credential selection, which needs compatibility review before merge.

Stored data model
Persistent data-model change detected: serialized state: src/hooks/bundled/session-memory/handler.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #89551
Summary: This PR is the active candidate fix for the canonical session-memory hook model override bug; older candidate PRs for the same behavior are closed unmerged, and the lightweight slug-model issue is broader adjacent work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦐 gold shrimp
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted terminal/log/live output, a recording, or a linked artifact from a real /reset or /new run showing the configured slug model used.
  • Use the embedded runner resolver or one shared helper instead of duplicating model resolution in the slug generator.
  • [P2] Add docs and focused tests for hook model forwarding, aliases, provider-qualified refs, bare names, and fallback behavior.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body supplies code-review rationale and snippets, not redacted terminal/log/live output, a recording, or an artifact from an after-fix hook run; the contributor should add redacted proof to the PR body so ClawSweeper can re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P2] Activating hooks.internal.entries.session-memory.model changes provider/model and credential routing for users who already have that open-ended hook key in config, but the supported values and fallback semantics are not documented or tested.
  • [P1] The PR resolves aliases/provider refs in llm-slug-generator even though runEmbeddedAgent already owns explicit model resolution, creating routing drift risk if the runner contract changes.
  • [P1] The submitted proof is code-review rationale and snippets only; it does not show redacted terminal output, live logs, a recording, or a linked artifact from an after-fix /reset or /new run.

Maintainer options:

  1. Centralize And Prove Hook Model Routing (recommended)
    Use the embedded runner resolver or one shared helper, add docs/tests for the hook model contract, and require redacted real hook-run proof before merge.
  2. Accept A Hook-Specific Contract
    Maintainers can explicitly accept session-memory.model as a supported hook config surface after documenting its accepted values and upgrade behavior.
  3. Pause For Broader Slug Policy
    If maintainers want a general lightweight slug-model setting instead, pause this PR and keep the broader policy in [Feature]: slug-generator: use lightweight model instead of agent primary to prevent lane congestion #33962.

Next step before merge

  • [P1] Human handling is needed because the PR still needs contributor real behavior proof and maintainer agreement on the session-memory.model contract before merge.

Security
Cleared: The diff changes existing TypeScript routing logic only and adds no dependencies, scripts, permissions, secrets handling, lockfiles, or supply-chain surfaces.

Review findings

  • [P1] Use the embedded runner's model resolver — src/hooks/llm-slug-generator.ts:108-119
  • [P2] Document the hook model contract — src/hooks/bundled/session-memory/handler.ts:236-241
  • [P2] Add focused coverage for hook model routing — src/hooks/llm-slug-generator.ts:108-119
Review details

Best possible solution:

Land a narrow fix that forwards session-memory.model through one canonical embedded model resolver, documents supported values and fallbacks, covers bare, alias, provider-qualified, and default cases, and includes redacted real /reset or /new proof.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection gives a high-confidence path: enable session-memory with llmSlug: true and a model value, then current main reads the hook config but calls slug generation without that model and resolves the agent default instead.

Is this the best way to solve the issue?

No, not as submitted. The narrow goal is right, but the best fix should avoid duplicating embedded-runner model resolution and should document/test the hook-level model contract with real hook-run proof.

Full review comments:

  • [P1] Use the embedded runner's model resolver — src/hooks/llm-slug-generator.ts:108-119
    This block resolves the hook model locally and then passes both provider and model to runEmbeddedAgent. The runner already resolves explicit model strings when provider is omitted, so this creates a second source of truth for alias, provider, and credential routing; forward the hook value through that path or extract one shared helper.
    Confidence: 0.87
  • [P2] Document the hook model contract — src/hooks/bundled/session-memory/handler.ts:236-241
    This starts consuming hooks.internal.entries.session-memory.model, but the bundled hook docs and public hooks page only define messages and llmSlug. Because this value changes provider/model routing, document accepted bare names, aliases, provider-qualified refs, and fallback behavior before merge.
    Confidence: 0.86
  • [P2] Add focused coverage for hook model routing — src/hooks/llm-slug-generator.ts:108-119
    The patch adds handler forwarding and provider/alias routing without regression coverage. Add focused tests for handler forwarding plus bare model, alias, provider-qualified ref, and default fallback behavior so this config route does not drift.
    Confidence: 0.84

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against eea777c9fc9c.

Label changes

Label justifications:

  • P2: The PR targets a bounded session-memory slug model-routing bug with limited blast radius but real provider/model impact.
  • merge-risk: 🚨 compatibility: Consuming session-memory.model creates active config behavior whose accepted values and fallback semantics are not documented or tested yet.
  • merge-risk: 🚨 auth-provider: The changed path can route slug generation to a different provider/model and therefore a different credential path.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body supplies code-review rationale and snippets, not redacted terminal/log/live output, a recording, or an artifact from an after-fix hook run; the contributor should add redacted proof to the PR body so ClawSweeper can re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +28. Total +28 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 2 31 3 +28
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 31 3 +28

What I checked:

  • Repository policy applied: Root AGENTS.md and scoped src/agents/AGENTS.md were read fully; provider/model routing, config-surface compatibility, best-fix, and real behavior proof rules affect this review. (AGENTS.md:24, eea777c9fc9c)
  • Current main drops the hook model: The session-memory handler reads hook config and gates on llmSlug, but calls generateSlugViaLLM({ sessionContent, cfg }) without forwarding hookConfig.model. (src/hooks/bundled/session-memory/handler.ts:208, eea777c9fc9c)
  • Current main resolves slug model from the agent default: generateSlugViaLLM accepts only sessionContent and cfg, then resolves provider/model through resolveDefaultModelForAgent, matching the linked bug report. (src/hooks/llm-slug-generator.ts:73, eea777c9fc9c)
  • Embedded runner already owns explicit model resolution: resolveInitialEmbeddedRunModel resolves explicit model strings via resolveModelRefFromString when provider is omitted, including aliases and provider-qualified refs. (src/agents/embedded-agent-runner/run.ts:546, eea777c9fc9c)
  • PR duplicates routing resolution before the runner: The PR head imports buildModelAliasIndex and resolveModelRefFromString, resolves the hook model locally, then passes both provider and model into runEmbeddedAgent. (src/hooks/llm-slug-generator.ts:108, cf4a6fe66004)
  • Docs do not define the new hook model contract: Session-memory bundled docs and the public hooks page describe messages and llmSlug, but not accepted model values, aliases, provider-qualified refs, or fallback behavior. (src/hooks/bundled/session-memory/HOOK.md:64, eea777c9fc9c)

Likely related people:

  • vincentkoc: Recent history includes session-memory and slug-generator maintenance, including configured slug timeout and release-adjacent touches to the affected files. (role: recent area contributor; confidence: high; commits: dfed74b2546d, 9f888d95e082, c645ec4555c0; files: src/hooks/llm-slug-generator.ts, src/hooks/bundled/session-memory/handler.ts)
  • steipete: Introduced the internal hooks system and merged the earlier slug-generator model-config fix that shaped this path. (role: feature introducer and merger; confidence: high; commits: faba508fe0ae, 588ad7fb381a; files: src/hooks/bundled/session-memory/handler.ts, src/hooks/bundled/session-memory/HOOK.md, src/hooks/llm-slug-generator.ts)
  • bigwest60: Authored the prior PR that changed the slug generator to respect configured agent model selection instead of hardcoded defaults. (role: model-routing contributor; confidence: high; commits: 588ad7fb381a; files: src/hooks/llm-slug-generator.ts)
  • SudeepMalipeddi: Authored the follow-up slug-generator change to use effective model resolution, directly adjacent to the current default-model behavior. (role: model-routing contributor; confidence: high; commits: d32298cbd816; files: src/hooks/llm-slug-generator.ts)
  • Roopak Nijhara: Added configurable session-memory message count in the same hook config area that this PR now extends by consuming model. (role: session-memory config contributor; confidence: medium; commits: 39b7f9d5817e; files: src/hooks/bundled/session-memory/handler.ts, src/hooks/bundled/session-memory/HOOK.md)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jun 19, 2026
…el name

Replace manual provider/model string splitting with simpler approach: keep default provider from resolveDefaultModelForAgent, only override the model name from hookConfig. This avoids bypassing the alias/configured-provider resolver.

Fixes openclaw#89551

Co-Authored-By: Claude <[email protected]>
@jincheng-xydt

Copy link
Copy Markdown
Contributor Author

Simplified the model override approach: now uses default provider from resolveDefaultModelForAgent and only overrides the model name. No manual string splitting that would bypass the alias resolver. @clawsweeper re-review

@jincheng-xydt

Copy link
Copy Markdown
Contributor Author

Regarding the provider routing concern: the hook config model field is documented as a model name override (e.g. "gpt-4o"), not a provider/model ref. The provider is always resolved from the agent default via resolveDefaultModelForAgent(). Only the plain model name is overridden when hookConfig.model is set.

The simplified approach in the latest commit removes the manual string splitting that could have caused issues. The model value is passed directly to runEmbeddedAgent as the model parameter alongside the default provider — no alias resolver is bypassed.

… provider/model refs

When the session-memory hook config specifies a model, use resolveModelRefFromString to properly resolve it. This handles both plain model names (gpt-4o) and provider/model refs (anthropic/claude-3-5-haiku) through the alias resolver, addressing ClawSweeper's concern about bypassing configured provider resolution.

Fixes openclaw#89551

Co-Authored-By: Claude <[email protected]>
@jincheng-xydt

Copy link
Copy Markdown
Contributor Author

Updated to use resolveModelRefFromString with buildModelAliasIndex for proper alias-aware model resolution. Both plain model names (gpt-4o) and provider/model refs (anthropic/claude-3-5-haiku) are now handled correctly. @clawsweeper re-review

@jincheng-xydt

Copy link
Copy Markdown
Contributor Author

Pushed empty commit to trigger re-evaluation. @clawsweeper re-review

@jincheng-xydt

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@jincheng-xydt

Copy link
Copy Markdown
Contributor Author

Closing this PR. Thanks to ClawSweeper for the thorough review — closing unmergeable work to keep the contribution signal clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: session-memory hook model config ignored for LLM slug generation

1 participant