Skip to content

fix(provider): cascade delete aliases on provider removal; persist token limits for custom models - #2020

Open
hamsa0x7 wants to merge 2 commits into
decolua:masterfrom
hamsa0x7:letta/fix-provider-aliases-tokens-bfe2f3ec
Open

hamsa0x7 wants to merge 2 commits into
decolua:masterfrom
hamsa0x7:letta/fix-provider-aliases-tokens-bfe2f3ec

Conversation

@hamsa0x7

Copy link
Copy Markdown
Contributor

Summary

Fix two custom provider issues: orphaned model aliases on deletion, and missing token limit persistence for custom models.

Changes

Fix #1409 — Cascade delete model aliases on provider removal

When a provider node is deleted, model aliases in the kv table (scope = modelAliases) that reference that provider were left orphaned. This blocked re-importing models on a recreated provider with the same prefix.

Files changed:

  • src/app/api/provider-nodes/[id]/route.js — Added deleteModelAliasesByProvider(id) call before node deletion
  • src/lib/db/repos/aliasRepo.js — Added deleteModelAliasesByProvider(providerId) function that deletes kv rows where value LIKE '{providerId}/%'
  • src/lib/db/index.js — Exported new function
  • src/models/index.js — Re-exported from models layer

Fix #1294 — Persist max_input_tokens / max_output_tokens for custom models

POST /api/models/custom only accepted providerAlias, id, type, and name, silently dropping maxInputTokens and maxOutputTokens fields. The DB storage also only persisted the 4 basic fields.

Files changed:

  • src/app/api/models/custom/route.js — Accepts maxInputTokens and maxOutputTokens from request body, passes to repo
  • src/lib/db/repos/aliasRepo.js — addCustomModel now accepts and stores maxInputTokens / maxOutputTokens in the JSON blob when provided

Test Plan

  • Unit tests pass (4 tests covering cascade delete SQL pattern, token inclusion, token omission, conditional token logic)

Notes

  • Token fields are optional — only stored when provided
  • Alias cleanup targets values that start with {providerId}/ which is the standard alias format

ozkancan-apk added a commit to ozkancan-apk/9routerFullFree that referenced this pull request Jun 24, 2026
…it), decolua#2020 (cascade delete + token limits), decolua#2018 (dynamic model fetch)

PR decolua#2046: SSE non-JSON satir + duplicate [DONE] fix. Stream kararlilik.
PR decolua#2007: 5 guvenlik yamasi (API key leak, proxy URL validation, XSS, MITM race, lock file).
PR decolua#2020: Provider silinince model alias cascade delete + custom model token limit.
PR decolua#2018: Custom provider'dan model listesi dinamik cekme.

+ onceki: betterSqliteAdapter transaction fix (createProviderConnection undefined hatasi).
@hamsa0x7 hamsa0x7 closed this Jun 25, 2026
@hamsa0x7
hamsa0x7 deleted the letta/fix-provider-aliases-tokens-bfe2f3ec branch June 25, 2026 14:33
@hamsa0x7
hamsa0x7 restored the letta/fix-provider-aliases-tokens-bfe2f3ec branch June 25, 2026 14:37
@hamsa0x7 hamsa0x7 reopened this Jun 25, 2026
afandiaziz added a commit to afandiaziz/9router that referenced this pull request Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant