8000 feat(reasoning): capability-driven thinking modes with LiteLLM discovery by qqqqqf-q · Pull Request #563 · felinics/Memoh · GitHub
[go: up one dir, main page]

Skip to content

feat(reasoning): capability-driven thinking modes with LiteLLM discovery - #563

Merged
sheepbox8646 merged 25 commits into
felinics:mainfrom
qqqqqf-q:feat/reason-effort-multi
Jun 13, 2026
Merged

sheepbox8646 merged 25 commits into
felinics:mainfrom
qqqqqf-q:feat/reason-effort-multi

Conversation

@qqqqqf-q
@qqqqqf-q qqqqqf-q commented Jun 3, 2026 •
Copy link
Copy Markdown
Member

Summary

  • Adds capability-driven thinking metadata to model config and provider templates: thinking_mode plus reasoning_efforts.
  • Adds cmd/synccaps, a build-time helper that enriches first-party conf/providers/*.yaml from the LiteLLM registry using canonical first-party matches only. It is not wired into server startup or runtime model import.
  • Updates model import/re-import so newly discovered capability fields refresh existing models by (provider_id, model_id), while compatibilities remain additive.
  • Reworks reasoning resolution into one call-time decision: thinking mode, user override, bot default, supported effort tiers, and provider wire type are resolved before SDK invocation.
  • Fixes provider wire behavior for the important edge cases: OpenAI-compatible Off no longer falls back to low; Anthropic 4.6+ uses adaptive/effort without legacy budgets; legacy Anthropic still uses budget_tokens.
  • Widens DB/API/frontend surfaces for minimal / max and dynamic model-specific effort lists.
  • Adds a weekly GitHub Action that opens YAML-only refresh PRs for provider capability metadata.

Design notes

  • Runtime truth remains local: provider templates plus provider SDK model lists. LiteLLM is used only by cmd/synccaps to prepare reviewed YAML diffs.
  • If a provider exposes a brand-new model before the template sync lands, runtime import still works; the new model may have incomplete reasoning metadata until a later sync/re-import refreshes it.
  • Re-import is intentionally a refresh path: present discovery replaces stale thinking_mode, reasoning_efforts, and context_window; existing compatibilities are preserved and extended.
  • The sync workflow currently uses the default GitHub Actions token. That is enough to create/update the automated PR when repository settings allow it, but PRs created by the default token may not trigger normal pull_request CI without a GitHub App/PAT follow-up.

Validation

  • go test -v -race -coverprofile=... -covermode=atomic ./...
  • go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.10.1 run ./...
  • pnpm install --frozen-lockfile && pnpm lint
  • pnpm --filter @memohai/desktop typecheck
  • pnpm --filter @memohai/desktop build:dir:online
  • SQLite migrations: migrate up -> down -> up
  • PostgreSQL migrations: migrate up -> down -> up
  • Docker builds passed on GitHub CI for server/web/sparse/vnc across amd64/arm64 on the previous head
  • go run ./cmd/synccaps -check
  • go run github.com/rhysd/actionlint/cmd/actionlint@latest .github/workflows/sync-model-capabilities.yml
  • Focused rebase smoke tests: go test ./internal/capabilities ./cmd/synccaps ./internal/models ./internal/conversation/flow ./internal/db

@qqqqqf-q
qqqqqf-q marked this pull request as ready for review June 3, 2026 17:14
@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d1bfbd0839

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/capabilities/discover.go Outdated
// them); none/minimal/xhigh/max are added when their explicit flags are set.
func deriveEffortLevels(e litellmEntry) []string {
present := map[string]bool{
models.ReasoningEffortLow: true,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Respect registry low-effort false

For models whose LiteLLM entry explicitly sets supports_low_reasoning_effort: false (the bundled snapshot contains gpt-5.5-pro/azure/gpt-5.5-pro with that flag), this seeding still imports low as supported. That makes the UI and resolver accept low for those models and can send an effort tier the provider says is unsupported; include low only when the flag is absent or true.

Useful? React with 👍 / 👎.

Comment thread internal/conversation/flow/resolver.go Outdated
return models.ReasoningEffortNone
}
}
return models.ReasoningEffortMinimal
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Choose a supported effort when disabling reasoning

When a toggle model does not advertise none or minimal (for example legacy/default low,medium,high imports, or registry entries where supports_minimal_reasoning_effort is false), selecting "Off" still returns minimal, and BuildReasoningOptions sends that unsupported tier to OpenAI-style providers. This can make chats fail exactly when users try to disable reasoning; fall back to the lowest advertised effective effort instead of an unconditional minimal.

Useful? React with 👍 / 👎.

@qqqqqf-q
qqqqqf-q commented Jun 3, 2026
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c551320a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/models/sdk.go Outdated
Comment on lines 114 to 118
if cfg.ReasoningConfig != nil && cfg.ReasoningConfig.Active && cfg.ReasoningConfig.Adaptive {
opts = append(opts, anthropicmessages.WithThinking(anthropicmessages.ThinkingConfig{
Type: "enabled",
BudgetTokens: budget,
Type: "adaptive",
}))
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve manual thinking for non-adaptive Claude models

For Anthropic models that resolve to toggle rather than adaptive (the bundled LiteLLM snapshot marks Claude 4.5 entries as supports_reasoning without supports_adaptive_thinking), resolveReasoningConfig sets Active=true but Adaptive=false. This branch then skips WithThinking entirely, and BuildReasoningOptions only sends output_config.effort; for those non-adaptive Claude models, effort alone does not enable extended thinking, so turning reasoning on in the UI silently runs without thinking. Please keep the old thinking: {type: "enabled", budget_tokens: ...} path for active non-adaptive Anthropic models while using adaptive for 4.6+.

Useful? React with 👍 / 👎.

@qqqqqf-q
qqqqqf-q commented Jun 3, 2026
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f810ab1453

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


PRAGMA foreign_keys = OFF;

ALTER TABLE bots RENAME TO bots_old;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve SQLite child foreign keys when rebuilding bots

When SQLite applies this migration on an existing database, ALTER TABLE bots RENAME TO bots_old rewrites child-table foreign keys that referenced bots to reference bots_old even with PRAGMA foreign_keys = OFF on current SQLite; after DROP TABLE bots_old, those constraints point at a missing table, so later inserts into child tables such as bot_sessions/routes can fail with no such table: main.bots_old. I verified the rename behavior with sqlite3; this migration should use the safer pattern used by 0013 (CREATE TABLE bots_new, copy from bots, drop old bots, then rename bots_new to bots) so dependent FKs continue to target bots.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Investigated empirically with golang-migrate Steps to isolate the cause; this is pre-existing main debt rather than a regression introduced by this PR.

Findings

  • The RENAME bots TO bots_old anti-pattern in SQLite predates this PR: it ships in 0005 and 0008 (both up/down). The safe bots_new rebuild pattern you reference is used by 0011/0012/0013. Those safe rebuilds only recreate bots itself and do not rewrite child-table FK text, so the child FKs damaged by 0008 are never repaired.
  • Scanning sqlite_master at version 14 (before this migration) vs 15 (after) shows the exact same 18 child tables already referencing bots_old (bot_sessions, schedule, containers, mcp_connections, ...). The set is identical and the diff of tables newly pointing at bots_old introduced by 0015 is empty — 0015 flips zero tables. At the point 0015 runs, every child already references the dangling bots_old from 0008, and a RENAME bots TO bots_old only rewrites references to bots, of which there are none, so net change is 0.
  • Switching 0015 to the bots_new pattern would not remove any of the 18 dangling refs (they originate in 0008 and the safe pattern doesn't repair child FK text), so the suggested fix is functionally a no-op for this symptom.
  • Severity is latent in practice: OpenSQLite does not enable PRAGMA foreign_keys (modernc default OFF), so the dangling refs are not enforced. The existing bot_sessions insert test passes through full migration for this reason.

Decision: Deferring in this PR. The dangling FKs are pre-existing main debt (0005/0007/0008) and 0015 adds zero net breakage. The real remedy is a dedicated migration that rebuilds the child tables' FKs back to bots/bot_sessions, which is out of scope here and will be tracked separately.

@qqqqqf-q
qqqqqf-q commented Jun 3, 2026
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e18a4ecd3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


PRAGMA foreign_keys = OFF;

ALTER TABLE bots RENAME TO bots_old;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Rebuild bots without renaming the parent table first

In existing SQLite databases, this ALTER TABLE ... RENAME rewrites dependent foreign keys even with PRAGMA foreign_keys = OFF (SQLite 3.26+ behavior; I also checked it with sqlite3). Tables that reference bots are updated to reference bots_old, and the migration later drops bots_old, so after applying 0015 those child tables point at a missing parent. Please use the existing bots_new/copy/drop/rename pattern from 0013 (or otherwise prevent FK rewriting) so references continue to target the final bots table.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Two things: (1) the rename in 0015 has now been converted to the safe bots_new copy/drop/rename pattern (same as 0013) in 768d6101, so this file no longer renames the parent table. (2) The dangling bots_old child FKs you flagged are pre-existing main debt and are not introduced by this PR — confirmed empirically, not asserted.

Provenance (vs origin/main): this PR's only SQLite migration diff is the newly-added 0015 plus a baseline edit to 0001. The ALTER TABLE bots RENAME TO bots_old anti-pattern lives only in 0005 and 0008, both shipped on main and byte-identical here (not in this PR's diff). 0011/0012/0013 already use the safe rebuild.

Empirical scan (golang-migrate Steps, scanning sqlite_master for tables whose sql references bots_old):

  • First appearance: v5 — 18 child tables (bot_sessions, schedule, containers, mcp_connections, user_input_requests, …).
  • v14 (pre-0015, == main tip): the same 18 tables.
  • v15 (after 0015): the identical 18 set. Tables newly pointing at bots_old introduced by 0015: 0 (empty diff).

So 0015 flips zero child FKs in either form. The original rename version was net-zero (children already referenced bots_old from 0005/0008 before 0015 ran), and the safe-pattern version is also net-zero. We've adopted the safe pattern anyway for consistency/convention, but the 18 dangling refs originate at v5/v8 and repairing them is main cleanup out of scope for this PR.

@qqqqqf-q
qqqqqf-q commented Jun 4, 2026
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 768d610171

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/capabilities/match.go Outdated
Comment on lines +170 to +171
if _, ok := knownPrefixSegments[rawTokens[0]]; ok {
rawTokens = rawTokens[1:]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid stripping model-family tokens as prefixes

When a provider returns IDs where the vendor token is also part of the model family, this loop collapses distinct models to generic names. In the bundled LiteLLM snapshot, deepseek/deepseek-coder and dashscope/qwen-coder both normalize to coder; because the index keeps the shortest key for a canonical, importing DeepSeek Coder matches dashscope/qwen-coder and fills Qwen's capabilities/context window (1M + reasoning) instead of DeepSeek's entry (128k, no reasoning flag). Prefix stripping should only remove gateway/vendor path segments that are not part of the final model slug, not family tokens inside the slug.

Useful? React with 👍 / 👎.

Comment on lines +10 to +11
ALTER TABLE bots ADD CONSTRAINT bots_reasoning_effort_check
CHECK (reasoning_effort IN ('none', 'low', 'medium', 'high', 'xhigh'));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize new effort values before restoring the CHECK

After the up migration allows values such as minimal, max, or other capability-driven tiers, this down migration fails as soon as any bot row contains one of those values: PostgreSQL rejects ADD CONSTRAINT, and the SQLite down rebuild has the same problem when copying into the constrained table. That leaves rollback broken for any installation that used the new effort tiers; map unsupported values back to a valid tier before re-adding the old constraint in both migration tracks.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in d84b0228. Both down tracks now reconcile relaxed tiers into the old ladder before re-adding the CHECK, so rollback no longer fails on installs that used the new values.

Mapping (both PostgreSQL and SQLite): minimal -> low, max -> xhigh, anything else outside ('none','low','medium','high','xhigh') -> medium (the column default).

  • PostgreSQL 0090 down: an UPDATE bots SET reasoning_effort = CASE ... END WHERE reasoning_effort NOT IN (...) runs before the ADD CONSTRAINT.
  • SQLite 0015 down: the same UPDATE runs right after PRAGMA foreign_keys = OFF and before the copy into the constrained bots_new, so the INSERT ... SELECT never carries an out-of-range value.

Verified on SQLite with a one-step rollback (v15 -> v14) seeded with max/minimal/super-custom/high rows: rollback now succeeds, values normalize to xhigh/low/medium/high, and bots_reasoning_effort_check is restored. The PostgreSQL statement is the direct analogue.

@qqqqqf-q
qqqqqf-q commented Jun 4, 2026
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 99e64834ab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/capabilities/match.go Outdated
// never folded into the base model.
var marketingSuffixTokens = map[string]struct{}{
"latest": {}, "preview": {}, "beta": {}, "online": {},
"thinking": {}, "nonthinking": {},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve thinking markers during matching

Because thinking/nonthinking are stripped as marketing suffixes, a provider that returns a bare base ID can inherit capabilities from a distinct thinking variant. For example, the bundled registry has reasoning-enabled kimi-k2-thinking entries and a non-thinking .../kimi-k2 shell; normalizing both to kimi-k2 lets a bare kimi-k2 resolve to the shorter thinking key and advertise reasoning when the served model may not support it. These tokens are capability-distinguishing and should remain part of the canonical signature.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Confirmed and fixed in e041def. Verified against the bundled snapshot: bare kimi-k2 was resolving to moonshot.kimi-k2-thinking (thinking=toggle, efforts=[low medium high]) because every */kimi-k2-thinking key stripped thinking and collapsed onto canonical kimi-k2.

Fix: moved thinking/nonthinking out of marketingSuffixTokens so they stay in the canonical signature, and added asymmetric matchThinkingBase:

  • bare kimi-k2 → .../kimi-k2 (thinking="", no reasoning advertised) ✓
  • kimi-k2-thinking → its own reasoning key ✓
  • claude-opus-4-8-thinking (no own key) → base claude-opus-4-8 (the marker is a runtime toggle on the same model) ✓

The fallback only fires when the marker is on the INPUT, so a bare base id can never borrow a distinct -thinking variant's capabilities. Added regression test TestMatch_ThinkingVariantNotBorrowedByBase.

@qqqqqf-q
qqqqqf-q commented Jun 4, 2026
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@qqqqqf-q
qqqqqf-q commented Jun 4, 2026
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@qqqqqf-q
qqqqqf-q force-pushed the feat/reason-effort-multi branch from 2ec4f7d to 2e78bfe Compare June 9, 2026 12:03
qqqqqf-q and others added 13 commits June 10, 2026 00:44
Discover model capabilities from the LiteLLM static registry and stop sending
token budgets, sending effort strings (plus adaptive for Anthropic 4.6+) instead.

- internal/capabilities: LiteLLM registry client (in-memory TTL + singleflight
  + fail-open) and model-name normalization/matching that maps provider names
  to canonical keys and derives thinking_mode/effort_levels/vision/context_window
- providers: warm capabilities in parallel with model listing; import now
  upsert-fills missing capability fields instead of skipping existing models
- models: ModelConfig gains thinking_mode; resolveReasoningConfig makes one
  decision per thinking mode; drop anthropic/google budget maps and never send
  budget_tokens to Anthropic
- db: relax bots_reasoning_effort_check (PG 0084 / SQLite 0009) so effort is a
  free-form capability-driven tier; widen settings validation accordingly
- web: settings + chat thinking UI render from thinking_mode/effort_levels;
  regenerate swagger + SDK
- go.mod: replace twilight-ai with local worktree pending an upstream tag

Co-authored-by: Cursor <cursoragent@cursor.com>
Subset fallback could let a sibling/variant id (deepseek-v4-pro,
gpt-5-mini, o4-mini-high, ...) borrow a base model's key when the
registry lacks the exact variant, inheriting the wrong context window
and capabilities. Restrict subset matching so extra tokens must all be
naming noise (vendor/region prefixes or marketing suffixes); any
distinguishing token (pro/mini/nano/flash/lite/plus/high/...) now blocks
the match and the variant safely MISSes instead of mis-filling.

Add a real-data match matrix (opt-in via LITELLM_REGISTRY_JSON) and a
regression test covering registry-has-base-but-not-variant.

Co-authored-by: Cursor <cursoragent@cursor.com>
The LiteLLM registry lists these as their own keys with their own
context windows and reasoning shapes (e.g. claude-opus-4.6-fast has a
128k window vs the base model's 1M; deepseek-v3.2-exp and grok
-fast-reasoning are separate keys). Folding them into the base via the
marketing-suffix list mis-filled siblings, so drop fast/exp/experimental
from marketingSuffixTokens. They now match their own key exactly or MISS
(safe default), never borrow the base. Keep only true release-channel
aliases (latest/preview/beta/online) and the thinking/nonthinking pair.

Co-authored-by: Cursor <cursoragent@cursor.com>
When the registry lacks an exact key for a low-latency "-fast" variant,
Lookup now falls back to the base model's reasoning shape (thinking
mode, effort tiers, vision, tool-call) so the variant still gets a
thinking toggle and effort options. The base context window is
explicitly dropped — latency variants frequently differ (e.g.
opus-4.6-fast is 128k vs the base 1M), so ctx must come from the
upstream provider or local default, never the base.

Scope is limited to latency variants (fast); pro/mini/nano/etc. whose
capabilities can genuinely differ still MISS when uncatalogued. The pure
match() layer is unchanged (still MISS); the fallback lives only in
Lookup. Adds Lookup test + matrix annotation for the fallback path.

Co-authored-by: Cursor <cursoragent@cursor.com>
…er main

Review fixes:
- normalize(): reBedrockVer was [-_]v\d+(:\d+)?$, which also ate legitimate
  bare version suffixes ("deepseek-v4" -> "deepseek", titan v1/v2 collapsing),
  bypassing the version veto. Tighten to [-_]v\d+:\d+$ so only bedrock-style
  colon revisions are stripped and real versions survive. Add regression test.
- buildIndex(): sort keys so byCanonical representative choice and fuzzy-tie
  winner are deterministic (map order was random).
- migrations: renumber relax_reasoning_effort from PG 0084 -> 0086 and SQLite
  0009 -> 0012 so they sort after origin/main's 0085/0010 (golang-migrate would
  otherwise skip them on existing DBs) and avoid the feat/ux-revamp 0084/0011
  collision. The SQLite table rebuild now uses heartbeat_interval DEFAULT 1440
  to preserve the change made by 0010 instead of reverting it to 30.

Co-authored-by: Cursor <cursoragent@cursor.com>
All 31 github_copilot/* registry entries carry zero reasoning flags and
expose Copilot's truncated context window (gpt-5 at 128k vs the real
272k). When a model is only catalogued under github_copilot/* (e.g.
claude-opus-4.6-fast), matching it inherits that empty shell and strips
the model's real reasoning capabilities. Skip github_copilot/copilot
keys when building the index so such models MISS and fall back to the
base reasoning shape (claude-opus-4.6-fast now resolves to opus-4-6's
only_adaptive shape, ctx dropped). Authoritative keys (e.g. bare gpt-5)
are unaffected.

Co-authored-by: Cursor <cursoragent@cursor.com>
…port + UI off-button dedup

- db.IsUniqueViolation: recognise SQLite SQLITE_CONSTRAINT (code & 0xff == 19)
  and a string-fallback for wrapped errors; was Postgres-only, breaking
  re-import on SQLite desktop — every existing model silently failed Create
  and was counted neither updated nor skipped (returned 0/0/0).
- handlers/providers: mergeDiscoveredConfig now overwrites stale capability
  fields (thinking_mode / reasoning_efforts / context_window) when a fresher
  discovery is available, instead of only filling blanks; fixes re-import not
  refreshing effort tiers (e.g. missing xhigh/max after first import).
- reasoning-effort-select.vue: remove hardcoded off-button; the "off" entry
  is already included by availableEffortsForMode(toggle) and absent for
  only_adaptive — the extra hardcoded button caused two 关闭 items for toggle
  models and a spurious off-switch for only_adaptive models.
- settings-interaction-card.vue: fix three TS2538/TS2345 type errors on
  reasoning_effort (string | undefined).

Co-authored-by: Cursor <cursoragent@cursor.com>
- db.IsUniqueViolation now checks SQLITE_CONSTRAINT_UNIQUE (2067) instead
  of the generic SQLITE_CONSTRAINT (19), preventing re-import fill from
  silently skipping existing models on SQLite/desktop.
- Migration comments in 0001_init.up.sql updated to reference correct
  numbers (PG 0086, SQLite 0012).
- Reverted provider-scoped re-import fill (GetByModelIDAndProviderID):
  cross-provider same-name models intentionally skip backfill when
  ambiguous — this is accepted behavior, not a bug.

Co-authored-by: Cursor <cursoragent@cursor.com>
qqqqqf-q and others added 11 commits June 10, 2026 00:44
PR felinics#17 merged into memohai/twilight-ai main (f4a48c3). Replace the
temporary qqqqqf-q fork `replace` with the upstream pseudo-version,
matching the repo's existing twilight-ai pinning convention (no tag).

Co-authored-by: Cursor <cursoragent@cursor.com>
- deriveEffortLevels: drop "low" from the implicit base when the registry
  sets supports_low_reasoning_effort: false (e.g. gpt-5.5-pro), so the UI
  and resolver never offer/send an unsupported tier.
- offEffortFor: when disabling reasoning, fall back to the lowest advertised
  effort instead of an unconditional "minimal" — models like gpt-5.5-pro
  advertise neither none nor minimal, so sending "minimal" failed the request
  exactly when users tried to turn reasoning off.
Toggle-mode Claude (<=4.5) silently lost extended thinking after the
effort migration: NewSDKChatModel only wired thinking{adaptive} for
adaptive models and sent nothing otherwise, but output_config.effort
alone does not enable thinking on pre-4.6 Claude. Restore the
thinking{type:"enabled", budget_tokens:N} path (5k/16k/50k by effort)
for non-adaptive active Anthropic calls, and gate output_config.effort
to adaptive models only.

Promote cloud-provider Claude 4.6+ variants (bedrock/vertex/azure/
openrouter) to adaptive when they advertise 4.6+ effort tiers but lack
supports_adaptive_thinking in the registry, keeping them off the legacy
budget path (budget_tokens is rejected with 400 on 4.7+).
…thout an off tier

Selecting "Off" on an OpenAI-wire model that advertises only low/medium/high
(e.g. Claude Opus 4.5 via OpenRouter) still produced thinking: offEffortFor fell
back to the lowest real tier ("low"), and OpenRouter translates
reasoning_effort:"low" into Anthropic extended thinking, so reasoning stayed on
exactly when the user turned it off. Verified against OpenRouter: "low" yields
reasoning, omitting the field yields none.

offEffortFor now returns "" when neither none nor minimal is advertised, and
openAIEffortOptions omits reasoning_effort entirely in that case so the provider
default (no thinking for toggle/Anthropic-compat models) applies. This also
fixes the prior P2 (sending an unsupported "minimal"/real tier on disable):
none -> none, minimal -> minimal, otherwise omit.
…aming parent

On SQLite 3.26+, ALTER TABLE bots RENAME TO bots_old rewrites dependent
child-table foreign keys to point at bots_old even with foreign_keys=OFF.
Since 0015 later drops bots_old, the rename pattern leaves child FKs
targeting a missing table. Switch both up/down to the safe
CREATE bots_new / copy / DROP bots / RENAME bots_new -> bots pattern used
by 0013, so child FKs keep targeting the final bots table.

Column set, relaxed/restored reasoning_effort_check, and indexes are
unchanged. Verified: full up drops the constraint with all columns
preserved (heartbeat_interval DEFAULT 1440), xhigh effort inserts, and
down/up round-trip is clean.
…CHECK on rollback

The up migrations relax reasoning_effort to free-form tiers (minimal/max/...),
so any bot row holding a relaxed value made the down migrations fail: PostgreSQL
ADD CONSTRAINT and the SQLite copy into the re-constrained table both reject
values outside ('none','low','medium','high','xhigh'), leaving rollback broken
for installs that used the new tiers.

Both down tracks now reconcile values into the old ladder before re-adding the
constraint: minimal -> low, max -> xhigh, anything else out of range -> medium
(the column default). Verified on SQLite: a one-step rollback with max/minimal/
custom rows now succeeds, normalizes correctly, and restores the constraint.
Two matching defects let the wrong LiteLLM entry fill a model's reasoning shape:

1. Cross-model fold: the post-unification prefix re-strip treated model-family
   vendor tokens (deepseek/qwen/mistral/meta/...) as strippable noise, collapsing
   distinct families to a generic tail — e.g. "deepseek-coder" and "qwen-coder"
   both normalized to "coder", so a non-reasoning coder borrowed a reasoning
   sibling's effort ladder. Vendor-family tokens are now kept on bare slugs
   (still ignorable for fuzzy subset matching, so "anthropic/claude-opus" still
   matches "claude-opus").

2. Provider-override loss: a fully-qualified id that is itself a registry key
   (e.g. "perplexity/anthropic/claude-haiku-4-5", which the registry marks
   supports_reasoning:false) was canonical-folded into the native reasoning
   entry and silently over-enabled thinking. The matcher now resolves an exact
   (case-insensitive) registry-key hit first; bare ids without provider context
   still default to the native entry.

Verified against the bundled snapshot: perplexity/* variants now resolve to
their own supports_reasoning:false entries, and deepseek-coder no longer
resolves to dashscope/qwen-coder. Added regression tests; full capabilities,
resolver, models and providers suites pass.
…shing

The model matcher stripped `thinking`/`nonthinking` as marketing suffixes,
collapsing a distinct reasoning variant (e.g. `kimi-k2-thinking`) onto the
bare base canonical (`kimi-k2`). A bare `kimi-k2` then resolved to the
thinking key and advertised reasoning the served model may not support.

Move these tokens out of marketingSuffixTokens so they stay in the canonical
signature, and add matchThinkingBase: only when the INPUT carries the marker
and the qualified variant has no own key do we fall back to the base model
(the marker is then a runtime toggle on the same base, e.g.
`claude-opus-4-8-thinking` -> `claude-opus-4-8`). This is asymmetric on
purpose: a bare base id can never borrow a distinct `-thinking` variant.
…shot

Prune the embedded LiteLLM snapshot to only the ~11 fields the matcher
consumes (litellmEntry in discover.go), shrinking it from a 69KB raw dump
to a 23KB deterministic projection while keeping runtime-visible content
byte-identical (only sample_spec is dropped; null fields are removed but
explicit false is preserved). registry.go is unchanged.

Add scripts/sync-litellm-snapshot.sh (curl+jq projection, sorted keys,
atomic write) with guards: valid JSON object, anchor models present, >=80%
entry-count floor, and >=80% per-field coverage floor for supports_reasoning
and max_input_tokens to catch an upstream field rename that would otherwise
silently null out capabilities.

Add .github/workflows/update-litellm-snapshot.yml (weekly cron +
workflow_dispatch) that runs the script, gates on decompressed content (not
gzip bytes, which vary across implementations), emits a field-level
added/removed/changed summary, and opens a PR.
…hment

OpenRouter model IDs (anthropic/claude-*, openai/gpt-*, google/gemini-*)
match upstream first-party entries via canonical equality, so they
inherit thinking_mode and reasoning_efforts from LiteLLM directly.

- Add openrouter to synccaps first-party list
- 76 OpenRouter models enriched (72 toggle + 3 adaptive + 1 other)
- Fix lint: add nolint annotations for build-time file reads
@qqqqqf-q
qqqqqf-q force-pushed the feat/reason-effort-multi branch from 2e78bfe to 9832983 Compare June 9, 2026 16:45
@sheepbox8646
sheepbox8646 merged commit caaf2e7 into felinics:main Jun 13, 2026
19 checks passed
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

0