Skip to content

Comments

fix(hooks): use configured primary model for slug generation (#14272)#14464

Open
lailoo wants to merge 2 commits intoopenclaw:mainfrom
lailoo:fix/slug-generator-model-14272
Open

fix(hooks): use configured primary model for slug generation (#14272)#14464
lailoo wants to merge 2 commits intoopenclaw:mainfrom
lailoo:fix/slug-generator-model-14272

Conversation

@lailoo
Copy link
Contributor

@lailoo lailoo commented Feb 12, 2026

Summary

Fixes #14272

Problem

generateSlugViaLLM in src/hooks/llm-slug-generator.ts hardcodes anthropic as the provider and claude-haiku as the model for slug generation. Users who configure a different primary model (e.g. openai/gpt-4.1-mini) still get Anthropic API calls, which fail if they don't have an Anthropic API key.

Fix

Use resolveConfiguredModelRef() to read the user's configured primary model and pass its provider/model to runEmbeddedPiAgent. Falls back to the original Anthropic defaults when no model is configured.

Reproduction & Verification

Before fix (main branch) — Bug confirmed:

  • src/hooks/llm-slug-generator.ts hardcodes provider: "anthropic" and modelId: "claude-haiku" — no test file exists on main.
  • Users with non-Anthropic configs get FailoverError when session-memory hook tries to generate slugs.

After fix — All verified:

✓ passes configured primary model to runEmbeddedPiAgent (#14272)
✓ falls back to default Anthropic model when no primary is configured
✓ returns cleaned slug from LLM response
✓ returns null when LLM returns no payloads
✓ returns null when LLM throws
5 tests pass (pnpm vitest run src/hooks/llm-slug-generator.test.ts)

Testing

  • ✅ 5 tests pass (pnpm vitest run src/hooks/llm-slug-generator.test.ts)
  • ✅ Lint passes

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines 19 to 22
describe("generateSlugViaLLM", () => {
it("passes configured primary model to runEmbeddedPiAgent (#14272)", async () => {
const cfg = {
agents: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mocks not reset

mockRunEmbeddedPiAgent is shared across all tests and its call history is never cleared, so assertions like toHaveBeenCalledWith(...) can be satisfied by calls from earlier test cases (false positives / order-dependent). Add a beforeEach(() => mockRunEmbeddedPiAgent.mockClear())/vi.clearAllMocks() or assert against the last/nth call (e.g., toHaveBeenLastCalledWith).

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/hooks/llm-slug-generator.test.ts
Line: 19:22

Comment:
**Mocks not reset**

`mockRunEmbeddedPiAgent` is shared across all tests and its call history is never cleared, so assertions like `toHaveBeenCalledWith(...)` can be satisfied by calls from earlier test cases (false positives / order-dependent). Add a `beforeEach(() => mockRunEmbeddedPiAgent.mockClear())`/`vi.clearAllMocks()` or assert against the last/nth call (e.g., `toHaveBeenLastCalledWith`).

How can I resolve this? If you propose a fix, please make it concise.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 12, 2026

Additional Comments (1)

src/hooks/llm-slug-generator.ts
Agent override ignored

This resolves agentId but then uses resolveConfiguredModelRef({ cfg: params.cfg, ... }), which ignores per-agent model overrides (see resolveDefaultModelForAgent in src/agents/model-selection.ts). If an agent has a specific primary model configured, slug generation will still use the global defaults model instead of the agent’s model.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/hooks/llm-slug-generator.ts
Line: 28:31

Comment:
**Agent override ignored**

This resolves `agentId` but then uses `resolveConfiguredModelRef({ cfg: params.cfg, ... })`, which ignores per-agent model overrides (see `resolveDefaultModelForAgent` in `src/agents/model-selection.ts`). If an agent has a specific primary model configured, slug generation will still use the global defaults model instead of the agent’s model.

How can I resolve this? If you propose a fix, please make it concise.

@lailoo lailoo force-pushed the fix/slug-generator-model-14272 branch from 2b7aa0c to 198ff92 Compare February 12, 2026 05:48
@openclaw-barnacle
Copy link

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: session-memory HOOK's generateSlugViaLLM Defaults to Anthropic Model, Ignores User's Configured Primary Model

1 participant