fix(hooks): use configured primary model for slug generation (#14272)#14464
fix(hooks): use configured primary model for slug generation (#14272)#14464lailoo wants to merge 2 commits intoopenclaw:mainfrom
Conversation
| describe("generateSlugViaLLM", () => { | ||
| it("passes configured primary model to runEmbeddedPiAgent (#14272)", async () => { | ||
| const cfg = { | ||
| agents: { |
There was a problem hiding this 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).
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.
Additional Comments (1)
This resolves Prompt To Fix With AIThis 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. |
2b7aa0c to
198ff92
Compare
198ff92 to
7ed7210
Compare
bfc1ccb to
f92900f
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
Summary
Fixes #14272
Problem
generateSlugViaLLMinsrc/hooks/llm-slug-generator.tshardcodesanthropicas the provider andclaude-haikuas 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 itsprovider/modeltorunEmbeddedPiAgent. 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.tshardcodesprovider: "anthropic"andmodelId: "claude-haiku"— no test file exists on main.FailoverErrorwhen session-memory hook tries to generate slugs.After fix — All verified:
Testing
pnpm vitest run src/hooks/llm-slug-generator.test.ts)