Skip to content

fix(ai): resolve opencodeModel "inherit" in profile cleanup - #508

Merged
EyJunge1 merged 3 commits into
tickernelz:mainfrom
ptitan:fix/ai-cleanup-inherit
Nov 18, 2026
Merged

EyJunge1 merged 3 commits into
tickernelz:mainfrom
ptitan:fix/ai-cleanup-inherit

Conversation

@ptitan

@ptitan ptitan commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

With opencodeModel: "inherit", the AI profile cleanup fails every time:

Generate.ModelNotFoundError: Model not found: <provider>/inherit

callViaOpencodeWithClient passed CONFIG.opencodeModel verbatim to session.prompt. Auto-capture is unaffected because it resolves "inherit" from the model recorded on the prompt; cleanup runs outside any prompt.

Changes in src/services/user-profile/ai-cleanup.ts:

  • Resolve the model with the existing resolveOpencodeModelRef (session model reported by chat.params, then OpenCode's recent model list) before session.create, so an unresolvable "inherit" fails with the helper's explicit error and no transient session is created.
  • Drop the unreachable hardcoded fallbacks bs-aigw / deepseek-v4-flash: callAICleanup only takes this path when both opencodeProvider and opencodeModel are set.

Configurations with an explicit model behave exactly as before.

Test plan

  • Exercised the change locally: two new cases in tests/ai-cleanup.test.ts, both failing on main and passing with this change
    • "inherit" is resolved from the recent model list and that model is sent to session.prompt
    • "inherit" with nothing to resolve returns the explicit error and never prompts
  • Noted any follow-up or known limitation: resolution needs a session model reported at least once (or model.json on v1 hosts); on a fresh host with no chat yet, cleanup now fails with an explicit message rather than a provider error

Checklist

  • Branch is based on main (do not open PRs from commits already on main)
  • bun test passes (or N/A) — one unrelated failure, config > CONFIG defaults > should keep the local embedding model loaded by default, which reads the local user config and fails identically on main
  • bun run typecheck passes (or N/A)
  • bun run check passes (format + lint + typecheck; or N/A)
  • Docs / README updated when behavior or contribution process changes — N/A, no behavior change for documented options

@ptitan
ptitan force-pushed the fix/ai-cleanup-inherit branch from 3e730b1 to 41f03d9 Compare November 17, 2026 15:12
Profile cleanup passed the configured model verbatim to session.prompt,
so `opencodeModel: "inherit"` reached OpenCode as a literal model id and
failed with `Generate.ModelNotFoundError: Model not found: <provider>/inherit`.
Auto-capture is unaffected because it resolves "inherit" from the prompt
record; cleanup has no prompt of its own.

Resolve the model with resolveOpencodeModelRef before creating the
transient session, so an unresolvable "inherit" fails with an explicit
message and no session is created.

Drop the unreachable hardcoded fallbacks (bs-aigw / deepseek-v4-flash):
callAICleanup only takes this path when both settings are configured.
@ptitan
ptitan force-pushed the fix/ai-cleanup-inherit branch from 41f03d9 to 06d73ce Compare November 17, 2026 15:23
Use the existing loader instead of a direct dynamic import, and extend
the cleanup test mock so resolveOpencodeModelRef still comes from the
real opencode-provider module.
@EyJunge1
EyJunge1 merged commit 75c7004 into tickernelz:main Nov 18, 2026
7 checks passed
@EyJunge1 EyJunge1 mentioned this pull request Nov 18, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants