Skip to content

fix(hooks): honor hook-level model override for session-memory slug generation - #89905

Closed
dwc1997 wants to merge 3 commits into
openclaw:mainfrom
dwc1997:fix/89551-slug-hook-model
Closed

dwc1997 wants to merge 3 commits into
openclaw:mainfrom
dwc1997:fix/89551-slug-hook-model

Conversation

@dwc1997

@dwc1997 dwc1997 commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

fix(hooks): honor hook-level model override for session-memory slug generation

Summary

Problem: The session-memory hook's llmSlug feature always used the agent's default model (via resolveDefaultModelForAgent), ignoring the hook-level model config. Users who set hooks.internal.entries.session-memory.model to a specific model found that the slug generator still used the default model.

Fix: Add an optional model parameter to generateSlugViaLLM. When provided, use splitModelRef to properly parse provider-qualified model strings (e.g. anthropic/claude-sonnet-4-6) instead of treating the entire string as a model-only ref. Pass hookConfig?.model from the session-memory handler.

Out of scope: No changes to model resolution logic, hook execution, or other hook types.

Linked context

Closes #89551

Real behavior proof

  • Behavior or issue addressed: Session-memory hook's model config is ignored for LLM slug generation, always using the agent's default model
  • Real environment tested: Windows 10, Node.js v22.11.0, OpenClaw latest main (commit dd0dd66, 2026-06-04)
  • Exact steps or command run after this patch: Ran splitModelRef via node --import tsx to verify provider-qualified model parsing, and ran regression tests via vitest
  • Evidence after fix: Terminal output showing the model parsing and tests passing:
$ node --import tsx -e "
import { splitModelRef } from './src/agents/subagent-spawn-plan.ts';

console.log('=== splitModelRef tests ===');

const result1 = splitModelRef('anthropic/claude-sonnet-4-6');
console.log('anthropic/claude-sonnet-4-6 =>', JSON.stringify(result1));

const result2 = splitModelRef('gpt-5.5');
console.log('gpt-5.5 =>', JSON.stringify(result2));

const result3 = splitModelRef('deepseek/deepseek-v4');
console.log('deepseek/deepseek-v4 =>', JSON.stringify(result3));

const result4 = splitModelRef(undefined);
console.log('undefined =>', JSON.stringify(result4));
"

=== splitModelRef tests ===
anthropic/claude-sonnet-4-6 => {"provider":"anthropic","model":"claude-sonnet-4-6"}
gpt-5.5 => {"model":"gpt-5.5"}
deepseek/deepseek-v4 => {"provider":"deepseek","model":"deepseek-v4"}
undefined => {}

$ node scripts/run-vitest.mjs src/hooks/llm-slug-generator.test.ts

 ✓  hooks  src/hooks/llm-slug-generator.test.ts
   ✓ generateSlugViaLLM
     ✓ keeps the helper default timeout when no agent timeout is configured
     ✓ marks the run lane-local so internal-helper failures do not poison shared profile health (#71709)
     ✓ honors configured agent timeoutSeconds for slow local providers
     ✓ infers provider metadata for bare configured agent models
     ✓ splits provider-qualified hook model override (regression #89551)
     ✓ uses hook model as model-only ref when no provider prefix (regression #89551)
     ✓ falls back to agent default when no hook model is provided (regression #89551)

 Test Files  1 passed (1)
      Tests  8 passed (8)
  • Observed result after fix: Provider-qualified model strings are properly split into provider and model parts. Model-only strings are treated as model-only refs. When no hook model is provided, the agent default is used.
  • What was not tested: Live session-memory hook run with real LLM call (requires API credentials)

Tests and validation

  • src/hooks/llm-slug-generator.test.ts: 3 new regression tests for provider-qualified override, model-only ref, and default fallback
  • No CHANGELOG.md edits

Risk checklist

  • userVisible: No (internal hook behavior, no user-facing change)
  • configEnvMigration: No
  • securityAuthNetwork: No
  • Mitigation: Only adds optional model parameter; backward compatible when not set

Current review state

  • Addressed ClawSweeper P1: Resolved hook model through existing provider/model parsing via splitModelRef
  • Addressed ClawSweeper P2: Added focused regression tests for provider-qualified override and default fallback behavior
  • Addressed ClawSweeper P1: Added real behavior proof showing splitModelRef correctly parses provider-qualified model strings
  • AI-assisted (built with Claude Code)

@openclaw-barnacle openclaw-barnacle Bot added size: XS proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 3, 2026
@clawsweeper

clawsweeper Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 6, 2026, 2:32 AM ET / 06:32 UTC.

Summary
The PR forwards hooks.internal.entries.session-memory.model into LLM slug generation and adds slug-generator regression tests for provider-qualified, model-only, and fallback cases.

PR surface: Source +5, Tests +44. Total +49 across 3 files.

Reproducibility: yes. source inspection gives a high-confidence reproduction path: current main reads the session-memory hook config but never forwards model, and the slug generator always resolves the agent default. I did not run a live /new or /reset hook call in this read-only review.

Review metrics: 1 noteworthy metric.

  • Existing hook config behavior changed: 1 existing per-hook key now honored. Users who already set hooks.internal.entries.session-memory.model can see provider/auth routing change after upgrade, so compatibility proof matters before merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof from a real setup is added.

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

Rank-up moves:

  • Resolve hook model values through OpenClaw's config/alias-aware model-selection path.
  • [P2] Document hooks.internal.entries.session-memory.model and add focused coverage for provider-qualified, alias, bare configured-provider, and fallback cases.
  • [P1] Add redacted real behavior proof from a /new or /reset session-memory hook run showing the configured model/provider was used.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body includes helper terminal output and mocked unit tests, but not a real after-fix /new or /reset session-memory hook run showing the configured model/provider was used. 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

  • [P1] Bare or alias session-memory hook model values can still route through the OpenAI default because the PR uses splitModelRef instead of config/alias-aware model selection.
  • [P1] Honoring this existing per-hook key can intentionally change provider, auth profile, endpoint, and cost behavior for users who already set it, so upgrade semantics need maintainer-visible proof.
  • [P1] The supplied proof does not show an actual /new or /reset session-memory hook path using the configured model after the patch.

Maintainer options:

  1. Fix resolver and proof before merge (recommended)
    Use config-aware model resolution for hook overrides, update docs/tests for the supported config key, and require redacted /new or /reset proof that the configured model/provider is used.
  2. Require provider-qualified semantics
    Maintainers could intentionally accept only provider-qualified session-memory hook models, but the PR should document that compatibility choice and avoid silently treating bare values as OpenAI.
  3. Pause the config-surface decision
    If hooks.internal.entries.session-memory.model should not become public yet, pause this PR and keep the linked issue for product-direction review.

Next step before merge

  • [P1] Human review remains appropriate because the branch needs a resolver/docs repair and contributor-supplied real behavior proof before merge.

Security
Cleared: No concrete security or supply-chain regression was found; the auth-provider concerns are functional routing risks covered by review findings and merge-risk labels.

Review findings

  • [P1] Resolve hook models through configured model selection — src/hooks/llm-slug-generator.ts:59
  • [P2] Document the session-memory model option — src/hooks/bundled/session-memory/handler.ts:236
Review details

Best possible solution:

Resolve the hook model through OpenClaw's config/alias-aware model-selection path, document the new session-memory model option and semantics, preserve default fallback behavior, and add redacted real hook-run proof before merge.

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

Yes, source inspection gives a high-confidence reproduction path: current main reads the session-memory hook config but never forwards model, and the slug generator always resolves the agent default. I did not run a live /new or /reset hook call in this read-only review.

Is this the best way to solve the issue?

No: forwarding the hook model is the right surface, but splitModelRef is too narrow for OpenClaw config semantics and the new config behavior still needs docs and real hook-run proof.

Full review comments:

  • [P1] Resolve hook models through configured model selection — src/hooks/llm-slug-generator.ts:59
    Using splitModelRef leaves bare or alias hook model values with provider: undefined; runEmbeddedAgent then defaults that provider to OpenAI, while the existing model-selection path can resolve aliases and infer a unique configured provider. A reported local/OpenAI-compatible bare model setup would still route slug generation through the wrong provider/auth path.
    Confidence: 0.91
  • [P2] Document the session-memory model option — src/hooks/bundled/session-memory/handler.ts:236
    This line makes hooks.internal.entries.session-memory.model a supported config behavior, but the bundled hook docs still list only messages and llmSlug. Please document the field and its provider/model or alias semantics so the new config surface is discoverable and upgrade-reviewable.
    Confidence: 0.82

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against c72c82726f20.

Label changes

Label justifications:

  • P2: This is a normal-priority session-memory slug-generation provider/model routing fix with limited blast radius.
  • merge-risk: 🚨 compatibility: The PR changes behavior for existing configs that already contain the session-memory hook model key.
  • merge-risk: 🚨 auth-provider: The changed slug-generator model selection can alter provider and auth-profile routing for the embedded helper run.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • 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 includes helper terminal output and mocked unit tests, but not a real after-fix /new or /reset session-memory hook run showing the configured model/provider was used. 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 +5, Tests +44. Total +49 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 11 6 +5
Tests 1 44 0 +44
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 55 6 +49

What I checked:

  • Current main ignores the hook model: saveSessionMemoryNow reads the session-memory hook config but currently calls generateSlugViaLLM({ sessionContent, cfg }), so a model entry cannot affect slug generation on main. (src/hooks/bundled/session-memory/handler.ts:208, c72c82726f20)
  • Current slug generator uses the agent default: generateSlugViaLLM currently resolves the default agent model and forwards that provider/model to runEmbeddedAgent. (src/hooks/llm-slug-generator.ts:56, c72c82726f20)
  • PR resolver is too narrow: The PR uses splitModelRef(params.model), which only splits on / and preserves bare refs with provider: undefined. (src/hooks/llm-slug-generator.ts:59, ad1972a16ac9)
  • Bare providers default to OpenAI: runEmbeddedAgent normalizes a missing provider with params.provider ?? DEFAULT_PROVIDER, and DEFAULT_PROVIDER is openai. (src/agents/embedded-agent-runner/run.ts:614, c72c82726f20)
  • Existing resolver handles configured bare models: resolveConfiguredModelRef can infer a unique provider from configured models for bare model strings before falling back to the default provider. (src/agents/model-selection-shared.ts:839, c72c82726f20)
  • Proof is helper-level, not hook-level: The PR body shows splitModelRef terminal output and mocked slug-generator tests, while explicitly saying a live session-memory hook run with a real LLM call was not tested. (ad1972a16ac9)

Likely related people:

  • Peter Steinberger: Introduced the internal hooks system, bundled session-memory handler, hook config types, and initial slug generator. (role: feature introducer; confidence: high; commits: faba508fe0ae; files: src/hooks/bundled/session-memory/handler.ts, src/hooks/llm-slug-generator.ts, src/config/types.hooks.ts)
  • Vincent Koc: Carried the slug-generator path forward with configured timeout/model-adjacent behavior and test coverage. (role: adjacent slug-generator contributor; confidence: medium; commits: dfed74b2546d; files: src/hooks/llm-slug-generator.ts, src/hooks/llm-slug-generator.test.ts)
  • Shakker: Current blame for the central hook and slug-generator files points to recent broad source work in this area. (role: recent area contributor; confidence: medium; commits: 1e683ff24537; files: src/hooks/bundled/session-memory/handler.ts, src/hooks/llm-slug-generator.ts, src/config/types.hooks.ts)
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 the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label Jun 3, 2026
@dwc1997
dwc1997 force-pushed the fix/89551-slug-hook-model branch from 4b22d15 to f4dd678 Compare June 4, 2026 14:07
@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: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 4, 2026
@dwc1997
dwc1997 force-pushed the fix/89551-slug-hook-model branch from f4dd678 to b221de1 Compare June 4, 2026 14:29
@dwc1997

dwc1997 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 4, 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.

Re-review progress:

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jun 4, 2026
@dwc1997
dwc1997 force-pushed the fix/89551-slug-hook-model branch from d36c0eb to 9ad1d94 Compare June 4, 2026 14:50
@dwc1997

dwc1997 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 4, 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.

Re-review progress:

@dwc1997
dwc1997 force-pushed the fix/89551-slug-hook-model branch 4 times, most recently from 88c63c2 to c047d2a Compare June 6, 2026 05:44
dwc1997 and others added 2 commits June 6, 2026 13:56
…eneration

The session-memory hook's llmSlug feature always used the agent's default
model, ignoring the hook-level model config. Now the hook-level model is
passed through to generateSlugViaLLM and used when provided.

Fixes openclaw#89551

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Use splitModelRef to properly parse provider-qualified model strings
(e.g. 'anthropic/claude-sonnet-4-6') instead of treating the entire
string as a model-only ref. This ensures the slug generator uses the
correct provider/auth path for hook-level model overrides.

Add regression tests for provider-qualified override, model-only ref,
and default fallback behavior.

Fixes openclaw#89551

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@dwc1997
dwc1997 force-pushed the fix/89551-slug-hook-model branch from c047d2a to eed1d2a Compare June 6, 2026 05:56
Add typeof check for hookConfig.model to ensure it's a string before
passing to generateSlugViaLLM. This fixes the TypeScript type error
where unknown was not assignable to string | undefined.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@dwc1997

dwc1997 commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

Closing: insufficient real behavior proof and high merge-risk (compatibility + auth-provider). The hook-level model override area requires deeper integration testing that this PR does not cover.

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: S 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