Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

feat(effort): die Leiter vom Katalog bis auf die Leitung

purple136eb2be9820
diff --git a/e2e/support/cloud-mock.ts b/e2e/support/cloud-mock.ts
index 76d2a52e..972931a8 100644
--- a/e2e/support/cloud-mock.ts
+++ b/e2e/support/cloud-mock.ts
@@ -143,6 +143,12 @@ export async function routeCloud(page: Page, scenario: CloudScenario): Promise<v
max_output_length: 8192,
input_modalities: ['text'],
think: 'toggle',
+ // The effort ladder, so the composer's effort control has
+ // something to render on the mocked catalogue too. The Llama
+ // entry above deliberately declares none: think 'never' models
+ // get no ladder from the server, and no control from us.
+ reasoning_effort_levels: ['low', 'medium', 'high'],
+ reasoning_effort_default: 'high',
},
],
}),
diff --git a/src/api/__tests__/provider-effort-ladder.test.ts b/src/api/__tests__/provider-effort-ladder.test.ts
new file mode 100644
index 00000000..cb918874
--- /dev/null
+++ b/src/api/__tests__/provider-effort-ladder.test.ts
@@ -0,0 +1,311 @@
+/**
+ * The chosen effort rung has to arrive on the wire, and a model that always
+ * reasons must never be sent 'none'.
+ *
+ * Companion to provider-think-off.test.ts, which nails the OFF switch. This
+ * file is the other direction: the rung the user picked in the composer, the
+ * ladder the server declared for that model, and what happens when the upstream
+ * refuses a rung anyway.
+ *
+ * Two live measurements from 2026-09-02 stand behind it
+ * (ops/wissen/deepinfra-modellmatrix-2026-09-02.md):
+ *
+ * - Qwen/Qwen3.8-27B answers 400 to 'high' and to 'max', naming 'low' and
+ * 'medium'. Dropping the parameter on that 400 hands the turn to the
+ * upstream default, which is the most expensive setting there is. Stepping
+ * one rung down keeps the reasoning AND the price the user asked for.
+ * - On GLM 5.3, 'none' does not stop the thinking. It only stops the upstream
+ * from separating it, so the monologue lands in the customer's chat window
+ * and costs more tokens than sending nothing at all. GLM 5.3 is a
+ * think:'always' model, so this file holds the rule that an always-reasoner
+ * never receives 'none'.
+ *
+ * Test isolation: the walk is remembered per endpoint, model AND rung in a
+ * static map, so every case below uses its own model name.
+ *
+ * Run: npx vitest run src/api/__tests__/provider-effort-ladder.test.ts
+ */
+import { describe, it, expect, vi, afterEach } from 'vitest'
+import { OpenAIProvider } from '../providers/openai-provider'
+import type { ProviderConfig } from '../providers/types'
+
+function makeConfig(overrides: Partial<ProviderConfig> = {}): ProviderConfig {
+ return {
+ id: 'lu-cloud',
+ name: 'LU Cloud',
+ enabled: true,
+ baseUrl: 'https://lu-labs.ai/api/inference/v1',
+ apiKey: 'test-key',
+ isLocal: false,
+ ...overrides,
+ }
+}
+
+const GLM53 = ['low', 'medium', 'high', 'max']
+const QWEN38_27B = ['minimal', 'low', 'medium']
+
+const ok = () => new Response(JSON.stringify({ choices: [{ message: { content: 'ok' } }] }), { status: 200 })
+const refuse = (status = 400) =>
+ new Response(JSON.stringify({ error: { message: 'Unexpected reasoning effort high.' } }), { status })
+const okStream = () => new Response('data: {"choices":[{"delta":{"content":"hi"}}]}\n\ndata: [DONE]\n\n', { status: 200 })
+
+const bodyOf = (spy: any, call: number) => JSON.parse(spy.mock.calls[call][1]?.body as string)
+
+async function drain(gen: AsyncGenerator<any>) {
+ for await (const _ of gen) { /* consume, the fetch only happens on first next() */ }
+}
+
+afterEach(() => vi.restoreAllMocks())
+
+describe('the rung the user picked is the rung that goes out', () => {
+ it('chatWithTools sends it', async () => {
+ const spy = vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(ok())
+ await new OpenAIProvider(makeConfig()).chatWithTools(
+ 'e-tools', [{ role: 'user', content: 'hi' }], [],
+ { thinking: true, reasoningEffort: 'low', effortLevels: GLM53 },
+ )
+ expect(bodyOf(spy, 0).reasoning_effort).toBe('low')
+ })
+
+ it('chatStream sends it too, that is the path a chat actually takes', async () => {
+ const spy = vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(okStream())
+ await drain(new OpenAIProvider(makeConfig()).chatStream(
+ 'e-stream', [{ role: 'user', content: 'hi' }],
+ { thinking: true, reasoningEffort: 'max', effortLevels: GLM53 },
+ ))
+ expect(bodyOf(spy, 0).reasoning_effort).toBe('max')
+ })
+
+ it('a wish above the model ladder is clamped before it leaves, not refused there', async () => {
+ const spy = vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(ok())
+ await new OpenAIProvider(makeConfig()).chatWithTools(
+ 'e-clamp', [{ role: 'user', content: 'hi' }], [],
+ { thinking: true, reasoningEffort: 'max', effortLevels: QWEN38_27B },
+ )
+ expect(spy).toHaveBeenCalledTimes(1)
+ expect(bodyOf(spy, 0).reasoning_effort).toBe('medium')
+ })
+})
+
+describe('a model that always reasons never gets none', () => {
+ // The composer keeps the Think button locked on for these, so `thinking`
+ // arrives undefined. Before the ladder existed that meant "send no knob at
+ // all"; with a declared ladder it means "send the rung, and only the rung".
+ it('THE RULE: thinking undefined plus a ladder sends the rung, never none', async () => {
+ const spy = vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(ok())
+ await new OpenAIProvider(makeConfig()).chatWithTools(
+ 'e-always', [{ role: 'user', content: 'hi' }], [],
+ { reasoningEffort: 'medium', effortLevels: GLM53 },
+ )
+ expect(bodyOf(spy, 0).reasoning_effort).toBe('medium')
+ expect(bodyOf(spy, 0).reasoning_effort).not.toBe('none')
+ })
+
+ it('and on the streaming path as well', async () => {
+ const spy = vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(okStream())
+ await drain(new OpenAIProvider(makeConfig()).chatStream(
+ 'e-always-stream', [{ role: 'user', content: 'hi' }],
+ { reasoningEffort: 'max', effortLevels: GLM53 },
+ ))
+ expect(bodyOf(spy, 0).reasoning_effort).toBe('max')
+ })
+
+ it('with no wish at all it still sends a rung, and the rung is not none', async () => {
+ const spy = vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(ok())
+ await new OpenAIProvider(makeConfig()).chatWithTools(
+ 'e-always-nowish', [{ role: 'user', content: 'hi' }], [], { effortLevels: GLM53 },
+ )
+ expect(bodyOf(spy, 0).reasoning_effort).toBe('high')
+ })
+})
+
+describe('a refused rung steps down the ladder instead of vanishing', () => {
+ it('THE MEASUREMENT: a 400 on high lands on medium, not on no knob', async () => {
+ const spy = vi.spyOn(globalThis, 'fetch')
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(ok())
+ await new OpenAIProvider(makeConfig()).chatWithTools(
+ 'e-step', [{ role: 'user', content: 'hi' }], [],
+ { thinking: true, reasoningEffort: 'high', effortLevels: ['low', 'medium', 'high'] },
+ )
+ expect(spy).toHaveBeenCalledTimes(2)
+ expect(bodyOf(spy, 1).reasoning_effort).toBe('medium')
+ })
+
+ it('walks further down while the upstream keeps refusing', async () => {
+ const spy = vi.spyOn(globalThis, 'fetch')
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(ok())
+ await new OpenAIProvider(makeConfig()).chatWithTools(
+ 'e-step-twice', [{ role: 'user', content: 'hi' }], [],
+ { thinking: true, reasoningEffort: 'max', effortLevels: GLM53 },
+ )
+ expect(spy).toHaveBeenCalledTimes(3)
+ expect(bodyOf(spy, 2).reasoning_effort).toBe('medium')
+ })
+
+ it('an accepted rung is never thrown away for the next one', async () => {
+ const spy = vi.spyOn(globalThis, 'fetch')
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(ok())
+ .mockResolvedValueOnce(ok())
+ await new OpenAIProvider(makeConfig()).chatWithTools(
+ 'e-stop-at-yes', [{ role: 'user', content: 'hi' }], [],
+ { thinking: true, reasoningEffort: 'max', effortLevels: GLM53 },
+ )
+ expect(spy).toHaveBeenCalledTimes(2)
+ expect(bodyOf(spy, 1).reasoning_effort).toBe('high')
+ })
+
+ it('and the knob is only dropped once the whole ladder is exhausted', async () => {
+ const spy = vi.spyOn(globalThis, 'fetch')
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(ok())
+ await new OpenAIProvider(makeConfig()).chatWithTools(
+ 'e-exhausted', [{ role: 'user', content: 'hi' }], [],
+ { thinking: true, reasoningEffort: 'high', effortLevels: ['low', 'medium', 'high'] },
+ )
+ expect(spy).toHaveBeenCalledTimes(4)
+ expect('reasoning_effort' in bodyOf(spy, 3)).toBe(false)
+ })
+
+ it('the step down NEVER lands on none, not even at the bottom of the ladder', async () => {
+ const spy = vi.spyOn(globalThis, 'fetch')
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(ok())
+ await new OpenAIProvider(makeConfig()).chatWithTools(
+ 'e-never-none', [{ role: 'user', content: 'hi' }], [],
+ { reasoningEffort: 'max', effortLevels: ['low', 'high', 'max'] },
+ )
+ const sent = spy.mock.calls.map((_c, i) => bodyOf(spy, i).reasoning_effort)
+ expect(sent).toEqual(['max', 'high', 'low', undefined])
+ expect(sent).not.toContain('none')
+ expect(sent).not.toContain('minimal')
+ })
+})
+
+describe('the memory belongs to one rung, not to the whole switch', () => {
+ it('what a refused max taught is not charged to low', async () => {
+ const provider = new OpenAIProvider(makeConfig())
+ vi.spyOn(globalThis, 'fetch')
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(ok())
+ await provider.chatWithTools(
+ 'e-rungs', [{ role: 'user', content: 'hi' }], [],
+ { thinking: true, reasoningEffort: 'max', effortLevels: ['low', 'medium', 'max'] },
+ )
+ vi.restoreAllMocks()
+
+ const spy = vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(ok())
+ await provider.chatWithTools(
+ 'e-rungs', [{ role: 'user', content: 'hi' }], [],
+ { thinking: true, reasoningEffort: 'low', effortLevels: ['low', 'medium', 'max'] },
+ )
+ expect(spy).toHaveBeenCalledTimes(1)
+ expect(bodyOf(spy, 0).reasoning_effort).toBe('low')
+ })
+
+ it('a rung that had to step down starts at the rung that worked next time', async () => {
+ const provider = new OpenAIProvider(makeConfig())
+ vi.spyOn(globalThis, 'fetch')
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(ok())
+ await provider.chatWithTools(
+ 'e-learned', [{ role: 'user', content: 'one' }], [],
+ { thinking: true, reasoningEffort: 'high', effortLevels: ['low', 'medium', 'high'] },
+ )
+ vi.restoreAllMocks()
+
+ const spy = vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(ok())
+ await provider.chatWithTools(
+ 'e-learned', [{ role: 'user', content: 'two' }], [],
+ { thinking: true, reasoningEffort: 'high', effortLevels: ['low', 'medium', 'high'] },
+ )
+ expect(spy).toHaveBeenCalledTimes(1)
+ expect(bodyOf(spy, 0).reasoning_effort).toBe('medium')
+ })
+
+ it('and the off switch keeps its own memory, untouched by any of it', async () => {
+ const provider = new OpenAIProvider(makeConfig())
+ vi.spyOn(globalThis, 'fetch')
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(refuse())
+ .mockResolvedValueOnce(ok())
+ await provider.chatWithTools(
+ 'e-lanes', [{ role: 'user', content: 'hi' }], [],
+ { thinking: true, reasoningEffort: 'high', effortLevels: ['low', 'medium', 'high'] },
+ )
+ vi.restoreAllMocks()
+
+ const spy = vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(ok())
+ await provider.chatWithTools('e-lanes', [{ role: 'user', content: 'hi' }], [], { thinking: false })
+ expect(bodyOf(spy, 0).reasoning_effort).toBe('none')
+ })
+})
+
+describe('an older server that declares no ladder changes nothing at all', () => {
+ it('thinking on is still exactly high', async () => {
+ const spy = vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(ok())
+ await new OpenAIProvider(makeConfig()).chatWithTools(
+ 'e-noladder-on', [{ role: 'user', content: 'hi' }], [], { thinking: true, reasoningEffort: 'low' },
+ )
+ expect(bodyOf(spy, 0).reasoning_effort).toBe('high')
+ })
+
+ it('thinking off is still exactly none', async () => {
+ const spy = vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(ok())
+ await new OpenAIProvider(makeConfig()).chatWithTools(
+ 'e-noladder-off', [{ role: 'user', content: 'hi' }], [], { thinking: false, reasoningEffort: 'max' },
+ )
+ expect(bodyOf(spy, 0).reasoning_effort).toBe('none')
+ })
+
+ it('and a model with no declared capability still sends no knob at all', async () => {
+ const spy = vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(ok())
+ await new OpenAIProvider(makeConfig()).chatWithTools(
+ 'e-noladder-undef', [{ role: 'user', content: 'hi' }], [], { reasoningEffort: 'max' },
+ )
+ expect('reasoning_effort' in bodyOf(spy, 0)).toBe(false)
+ })
+})
+
+describe('the catalogue carries the ladder from the server to the composer', () => {
+ it('reasoning_effort_levels and reasoning_effort_default survive listModels', async () => {
+ vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(
+ new Response(JSON.stringify({
+ object: 'list',
+ data: [{
+ id: 'zai-org/GLM-5.3', object: 'model', owned_by: 'lu-labs', name: 'GLM 5.3',
+ context_length: 1_048_576, input_modalities: ['text'], think: 'always',
+ supports_tools: true,
+ reasoning_effort_levels: ['low', 'medium', 'high', 'max'],
+ reasoning_effort_default: 'high',
+ }],
+ }), { status: 200 }),
+ )
+ const models = await new OpenAIProvider(makeConfig()).listModels()
+ expect(models[0].effortLevels).toEqual(['low', 'medium', 'high', 'max'])
+ expect(models[0].effortDefault).toBe('high')
+ expect(models[0].thinkMode).toBe('always')
+ })
+
+ it('a server that sends neither field leaves both undefined, and that is the off switch for the control', async () => {
+ vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(
+ new Response(JSON.stringify({
+ object: 'list',
+ data: [{ id: 'old/model', object: 'model', name: 'Old', context_length: 8192, think: 'toggle' }],
+ }), { status: 200 }),
+ )
+ const models = await new OpenAIProvider(makeConfig()).listModels()
+ expect(models[0].effortLevels).toBeUndefined()
+ expect(models[0].effortDefault).toBeUndefined()
+ })
+})
diff --git a/src/api/providers/openai-provider.ts b/src/api/providers/openai-provider.ts
index 0f307fc0..7dfb90e1 100644
--- a/src/api/providers/openai-provider.ts
+++ b/src/api/providers/openai-provider.ts
@@ -21,6 +21,7 @@ import { parseRetryAfter } from '../../lib/http-status'
import { localFetch, localFetchStream, isPrivateOrLanHost, isDirectFetchAllowed, hostnameOf, ensureProxyAllowsHost, backendCall } from '../backend'
import { ensureBuiltinEngineAlive, explainDeadEngine, explainEngineTransportMessage, isManagedBuiltinSlot } from '../builtin-ensure'
import { applyTemplateContract } from './normalize-system'
+import { clampEffort, hasEffortLadder, lowerEffort, DEFAULT_EFFORT } from '../../lib/effort'
// Transport routing lives in the `useLocalProxy` getter (below) plus the shared
// host helpers in backend.ts. A direct webview fetch only works for hosts the
@@ -83,6 +84,13 @@ interface OpenAIModelEntry {
// it → the mapping falls back to `true` (optimistic, corrected at runtime).
supports_tools?: boolean
think?: 'toggle' | 'always' | 'never'
+ // The reasoning rungs this model accepts, ascending, and the one it defaults
+ // to. LU Cloud sends both for every model that reasons and neither for a
+ // `think: 'never'` one. Absent everywhere else, and absent on an LU Cloud
+ // deployment that predates 2.6.8, which is why every reader below treats a
+ // missing ladder as "keep doing exactly what you did before".
+ reasoning_effort_levels?: string[]
+ reasoning_effort_default?: string
}
// ── Known context lengths for popular models ───────────────────
@@ -273,12 +281,54 @@ export class OpenAIProvider implements ProviderClient {
* answers 400. So sendChat walks the knob down instead of swapping it, and
* remembers how far it had to walk, per endpoint and model.
*/
- private thinkingEffort(model: string, thinking: boolean | undefined): string | undefined {
- if (thinking === undefined) return undefined
- const walked = OpenAIProvider.effortMemory.get(this.catalogKey(model))
- if (thinking === true) return walked?.on === 'omit' ? undefined : 'high'
- if (walked?.off === 'omit') return undefined
- return walked?.off === 'minimal' ? 'minimal' : 'none'
+ private thinkingEffort(
+ model: string,
+ thinking: boolean | undefined,
+ options?: ChatOptions,
+ ): string | undefined {
+ const levels = options?.effortLevels
+ const ladder = hasEffortLadder(levels)
+ // No wish and no declared ladder: send nothing, exactly as before. A model
+ // that always reasons and a model that never does both arrive here with
+ // `thinking` undefined, and on a server that does not declare rungs they
+ // keep deciding for themselves.
+ if (thinking === undefined && !ladder) return undefined
+
+ // OFF stays OFF, on its own lane and with its own memory. A model whose
+ // catalogue entry says it always reasons never reaches this branch: the
+ // composer keeps its Think button locked on, so 'none' is never asked for
+ // it. That matters in money: on GLM 5.3 'none' does not stop the thinking,
+ // it only stops the upstream from separating it, so the monologue lands in
+ // the customer's chat window and costs MORE than sending nothing.
+ if (thinking === false) {
+ const walkedOff = OpenAIProvider.effortMemory.get(this.effortKey(model, 'off'))
+ if (walkedOff?.off === 'omit') return undefined
+ return walkedOff?.off === 'minimal' ? 'minimal' : 'none'
+ }
+
+ // ON: the wish, clamped onto the rungs this model really has. Without a
+ // ladder that is DEFAULT_EFFORT, which is the 'high' this client has always
+ // sent.
+ const wanted = ladder
+ ? clampEffort(levels, options?.reasoningEffort ?? DEFAULT_EFFORT)
+ : DEFAULT_EFFORT
+ const walked = OpenAIProvider.effortMemory.get(this.effortKey(model, 'on', wanted))
+ if (walked?.on === 'omit') return undefined
+ return walked?.on ?? wanted
+ }
+
+ /**
+ * Memory key for one lane of the walk.
+ *
+ * The OFF lane is a single switch position, so one key per model does. The ON
+ * lane has as many positions as the model has rungs and they are NOT
+ * interchangeable: Qwen/Qwen3.8-27B answers 400 to 'high' and serves
+ * 'medium' without complaint (live measurement 2026-09-02). Keyed by rung,
+ * what a refused 'max' teaches can never be charged to 'low'.
+ */
+ private effortKey(model: string, lane: 'on' | 'off', rung?: string): string {
+ const base = this.catalogKey(model)
+ return lane === 'off' ? base : `${base}#${rung ?? DEFAULT_EFFORT}`
}
/**
@@ -315,11 +365,13 @@ export class OpenAIProvider implements ProviderClient {
return { enable_thinking: thinking }
}
- /** Remember a walk, for one direction of the switch only. */
- private rememberEffort(model: string, lane: 'on' | 'off', value: 'minimal' | 'omit'): void {
- const key = this.catalogKey(model)
+ /** Remember a walk, for one lane and one rung only. */
+ private rememberEffort(key: string, lane: 'on' | 'off', value: string): void {
const prev = OpenAIProvider.effortMemory.get(key) ?? {}
- OpenAIProvider.effortMemory.set(key, { ...prev, [lane]: value })
+ const next = { ...prev }
+ if (lane === 'on') next.on = value
+ else next.off = value === 'omit' ? 'omit' : 'minimal'
+ OpenAIProvider.effortMemory.set(key, next)
}
/**
@@ -344,6 +396,7 @@ export class OpenAIProvider implements ProviderClient {
body: Record<string, any>,
signal: AbortSignal | undefined,
fetcher: (url: string, init: any) => Promise<Response>,
+ levels?: string[],
): Promise<Response> {
const post = () => fetcher(`${this.baseUrl}/chat/completions`, {
method: 'POST',
@@ -354,8 +407,13 @@ export class OpenAIProvider implements ProviderClient {
const refused = (res: Response) => !res.ok && (res.status === 400 || res.status === 422)
const asked = body.reasoning_effort as string | undefined
+ // 'none' and 'minimal' are the two ways of saying off; every other rung is
+ // the ON lane. Reading it off the value rather than off 'high' is what lets
+ // 'low', 'medium' and 'max' keep their own memory instead of borrowing the
+ // off switch's.
const lane: 'on' | 'off' | undefined =
- asked === undefined ? undefined : asked === 'high' ? 'on' : 'off'
+ asked === undefined ? undefined : asked === 'none' || asked === 'minimal' ? 'off' : 'on'
+ const memoryKey = lane === undefined ? '' : this.effortKey(model, lane, asked)
// Stop ends the walk. The real fetch rejects on an aborted signal on its
// own, but localFetchStream's proxy path used to fire the request anyway,
@@ -369,6 +427,22 @@ export class OpenAIProvider implements ProviderClient {
res = await post()
}
+ // ON lane: step DOWN the model's own ladder before giving the knob up.
+ // Qwen/Qwen3.8-27B refuses 'high' and 'max' with a 400 and reasons happily
+ // at 'medium' (live measurement 2026-09-02); dropping the field instead
+ // hands the turn to the upstream default, which is the most expensive
+ // setting there is. The walk stops at the first rung that is accepted, so
+ // an accepted rung is never thrown away for the sake of the next one.
+ if (lane === 'on' && levels?.length) {
+ for (let step = levels.length; step > 0; step--) {
+ if (stopped() || !refused(res)) break
+ const lower = lowerEffort(levels, body.reasoning_effort as string)
+ if (!lower) break
+ body.reasoning_effort = lower
+ res = await post()
+ }
+ }
+
// Its own rung, ahead of both the knob and stream_options: a server that
// refuses the template kwargs must not be remembered as one that cannot
// think. Dropped for the whole endpoint once it succeeds without it, so
@@ -391,8 +465,8 @@ export class OpenAIProvider implements ProviderClient {
if (res.ok && lane) {
const survived = body.reasoning_effort as string | undefined
- if (survived === undefined) this.rememberEffort(model, lane, 'omit')
- else if (survived !== asked) this.rememberEffort(model, lane, 'minimal')
+ if (survived === undefined) this.rememberEffort(memoryKey, lane, 'omit')
+ else if (survived !== asked) this.rememberEffort(memoryKey, lane, survived)
}
return res
@@ -476,7 +550,7 @@ export class OpenAIProvider implements ProviderClient {
// Reasoning-model knob (o1, o3, gpt-5-thinking, etc.). Toggle ON → "high",
// toggle OFF → "none". Non-reasoning models simply ignore the field; an
// endpoint that rejects it is handled by the ladder in sendChat.
- const effort = this.thinkingEffort(model, options?.thinking)
+ const effort = this.thinkingEffort(model, options?.thinking, options)
if (effort) body.reasoning_effort = effort
// The knob a template-rendering backend actually reads. See
// templateThinkingKwargs for the counter-check that reasoning_effort
@@ -498,7 +572,7 @@ export class OpenAIProvider implements ProviderClient {
if (this.useLocalProxy) await ensureProxyAllowsHost(this.baseUrl)
const fetcher = this.useLocalProxy ? localFetchStream : fetch
- const res = await this.sendChat(model, body, options?.signal, fetcher as any)
+ const res = await this.sendChat(model, body, options?.signal, fetcher as any, options?.effortLevels)
if (!res.ok) {
throw await this.parseError(res)
@@ -643,7 +717,7 @@ export class OpenAIProvider implements ProviderClient {
if (options?.topP !== undefined) body.top_p = options.topP
await this.applyMaxTokens(model, body, options)
// Same reasoning_effort gate as chatStream.
- const effort = this.thinkingEffort(model, options?.thinking)
+ const effort = this.thinkingEffort(model, options?.thinking, options)
if (effort) body.reasoning_effort = effort
// Same template-kwargs gate as chatStream.
const tmplKwargs = this.templateThinkingKwargs(options?.thinking)
@@ -655,7 +729,7 @@ export class OpenAIProvider implements ProviderClient {
if (this.useLocalProxy) await ensureProxyAllowsHost(this.baseUrl)
const fetcher = this.useLocalProxy ? localFetch : fetch
- const res = await this.sendChat(model, body, options?.signal, fetcher as any)
+ const res = await this.sendChat(model, body, options?.signal, fetcher as any, options?.effortLevels)
if (!res.ok) {
throw await this.parseError(res, tools.length > 0)
@@ -745,6 +819,11 @@ export class OpenAIProvider implements ProviderClient {
supportsTools: m.supports_tools ?? true,
supportsVision: m.input_modalities?.includes('image') || undefined,
thinkMode: m.think,
+ // Straight through, no invention: a server that does not declare the
+ // ladder leaves both undefined, and undefined is what switches the
+ // whole effort feature off for this model.
+ effortLevels: m.reasoning_effort_levels,
+ effortDefault: m.reasoning_effort_default,
}
})
}
@@ -894,7 +973,10 @@ export class OpenAIProvider implements ProviderClient {
* the switch ON. One shared entry made a single OFF message silence the
* user's thinking switch for the rest of the session.
*/
- private static effortMemory = new Map<string, { on?: 'omit'; off?: 'minimal' | 'omit' }>()
+ // Keyed by effortKey(): one entry per model for the OFF lane, one per model
+ // AND rung for the ON lane. `on` holds either 'omit' or the rung the upstream
+ // actually accepted after a walk down the ladder.
+ private static effortMemory = new Map<string, { on?: string; off?: 'minimal' | 'omit' }>()
/**
* Endpoints that refused `chat_template_kwargs`. Keyed by base URL, not by
diff --git a/src/api/providers/types.ts b/src/api/providers/types.ts
index 64888b92..c5f7e06b 100644
--- a/src/api/providers/types.ts
+++ b/src/api/providers/types.ts
@@ -113,6 +113,14 @@ export interface ProviderModel {
* the switch, 'always' reasons regardless, 'never' hides it. Absent =
* fall back to the local name-heuristic. */
thinkMode?: 'toggle' | 'always' | 'never'
+ /** The reasoning rungs this model really accepts, ascending (LU Cloud
+ * /models `reasoning_effort_levels`). Absent on every other backend and on
+ * a server that predates the field, and absent means no effort control and
+ * the old fixed behaviour. See lib/effort.ts. */
+ effortLevels?: string[]
+ /** The rung the model itself defaults to (`reasoning_effort_default`). Used
+ * only where no wish was made; the user's own choice always wins. */
+ effortDefault?: string
}
// ── Chat Messages (unified format) ────────────────────────────
@@ -141,6 +149,19 @@ export interface ChatOptions {
topK?: number // Ollama/Anthropic support this, OpenAI doesn't
maxTokens?: number
thinking?: boolean // Enable model thinking/reasoning mode
+ /**
+ * Which rung of the reasoning ladder to ask for while thinking is on
+ * (2.6.8). Meaningful only together with `effortLevels`; without a declared
+ * ladder the provider keeps sending what it always sent.
+ */
+ reasoningEffort?: string
+ /**
+ * The rungs the ACTIVE model declares, ascending, straight from the server
+ * catalogue. The caller passes them because the model row is what knows
+ * them; the provider clamps the wish onto them and walks them down if the
+ * upstream still refuses. Absent = no ladder = old behaviour.
+ */
+ effortLevels?: string[]
// Bug AA v2.5.0 — Kj103x Discord 2026-05-27. Ollama defaults `num_ctx` to
// 2048 if you don't pass it in /api/chat options, which silently caps RAG
// and long-turn chats even though the loaded model supports way more. When
diff --git a/src/hooks/useModels.ts b/src/hooks/useModels.ts
index 9c048ed2..50b915fb 100644
--- a/src/hooks/useModels.ts
+++ b/src/hooks/useModels.ts
@@ -194,6 +194,12 @@ export function useModels() {
provider: pm.provider, providerName: pm.providerName,
contextLength: pm.contextLength, supportsTools: pm.supportsTools, supportsVision: pm.supportsVision,
thinkMode: pm.thinkMode,
+ // The effort ladder rides along field by field, like thinkMode.
+ // The Ollama branch above is the standing warning: a literal that
+ // rebuilds the model and stops one field short is how a server
+ // answer dies quietly halfway to the composer.
+ effortLevels: pm.effortLevels,
+ effortDefault: pm.effortDefault,
// Friendly server label (LU Cloud) — pickers prefer it over the id.
displayName: pm.name !== pm.id ? pm.name : undefined,
} satisfies CloudModel
diff --git a/src/types/models.ts b/src/types/models.ts
index 4bee92d4..df17850d 100644
--- a/src/types/models.ts
+++ b/src/types/models.ts
@@ -34,6 +34,11 @@ export interface CloudModel {
supportsTools?: boolean
supportsVision?: boolean
thinkMode?: 'toggle' | 'always' | 'never'
+ /** The reasoning rungs this model accepts, ascending, and the rung it
+ * defaults to (LU Cloud /models). Absent = no effort control and the old
+ * fixed behaviour. See lib/effort.ts. */
+ effortLevels?: string[]
+ effortDefault?: string
/** Friendly picker label when the server provides one (LU Cloud /models
* `name`) — pickers fall back to the raw id otherwise. */
displayName?: string