#15574: fix(hooks): use configured model for llm slug generation (#15510)
gateway
stale
size: S
Cluster:
Model Configuration Enhancements
## Summary
Fixes `session-memory` / `llm-slug-generator` using hardcoded Anthropic defaults by explicitly inheriting the configured agent default model.
Closes #15510.
## Problem
`generateSlugViaLLM()` called `runEmbeddedPiAgent()` without provider/model, which falls back to global defaults (`anthropic/claude-opus-4-6`).
In setups without Anthropic auth, this causes slug generation to fail despite a valid configured primary model/provider.
## Root Cause
The slug generator resolved agent/workspace context but did not resolve and pass the configured default model reference.
## Changes
- `src/hooks/llm-slug-generator.ts`
- Resolve default model via `resolveDefaultModelForAgent({ cfg, agentId })`.
- Pass `provider` + `model` explicitly into `runEmbeddedPiAgent()`.
- `src/hooks/llm-slug-generator.test.ts` (new)
- Verifies configured model (`minimax/MiniMax-M2.5`) is used for slug generation calls.
- Verifies fallback to built-in defaults when no model is configured.
## Tests
- `pnpm vitest run src/hooks/llm-slug-generator.test.ts src/hooks/bundled/session-memory/handler.test.ts`
- Passed (12/12).
- `pnpm vitest run src/hooks/bundled/session-memory/handler.test.ts src/infra/heartbeat-runner.returns-default-unset.test.ts`
- Passed (43/43).
## Sign-Off
lobster-biscuit
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the LLM slug generator hook to explicitly inherit the configured default model (via `resolveDefaultModelForAgent`) and pass `provider`/`model` into `runEmbeddedPiAgent`, preventing fallback to the hardcoded Anthropic defaults when a non‑Anthropic primary model is configured.
It also adds a focused unit test that mocks the embedded agent runner and agent scope resolution to assert:
- a configured default model (e.g. `minimax/MiniMax-M2.5`) is propagated into the embedded run
- the built-in defaults (`anthropic/claude-opus-4-6`) are used when no model is configured
Overall, the change fits cleanly into existing model-selection infrastructure (`src/agents/model-selection.ts`) and leverages the same default constants used by the embedded runner (`src/agents/defaults.ts`).
<h3>Confidence Score: 4/5</h3>
- This PR is likely safe to merge, with one test-shape issue to address.
- The runtime change is small and uses the existing model-resolution helper to avoid unintended Anthropic fallbacks; the main remaining concern is that the new test may be using a config shape that doesn’t match what `OpenClawConfig` actually supports in practice, which can lead to brittle or misleading coverage.
- src/hooks/llm-slug-generator.test.ts
<sub>Last reviewed commit: 4faff63</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#4793: hooks: use configured model for slug generator
by yoyooyooo · 2026-01-30
92.5%
#5945: fix: use configured model for slug generator (AI-assisted)
by HEDELKA · 2026-02-01
91.4%
#23286: fix: use configured model in llm-slug-generator instead of hardcoded …
by wsman · 2026-02-22
90.8%
#9080: Fix: Use configured model for memory file slug generation
by vishaltandale00 · 2026-02-04
89.3%
#13401: fix: slug generator should use agent's primary model instead of har...
by pahud · 2026-02-10
88.9%
#18867: fix: route slug generator LLM call through configured provider
by Celegormhenry · 2026-02-17
86.2%
#12459: feat(session-memory): add model config for slug generation
by akari-musubi · 2026-02-09
85.5%
#14464: fix(hooks): use configured primary model for slug generation (#14272)
by lailoo · 2026-02-12
83.5%
#21735: fix(hooks): pass configured model to slug generator (#21650)
by lailoo · 2026-02-20
82.2%
#20712: fix(subagents): prioritize agent runtime default model over global ...
by sourcesavant · 2026-02-19
79.4%