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.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(effort): effortDefault bekommt eine Aufgabe statt nur einen Typ
purple47754cd9f5c7
diff --git a/src/api/__tests__/provider-effort-ladder.test.ts b/src/api/__tests__/provider-effort-ladder.test.tsindex 375be3f4..f40e20b8 100644--- a/src/api/__tests__/provider-effort-ladder.test.ts+++ b/src/api/__tests__/provider-effort-ladder.test.ts@@ -79,6 +79,24 @@ describe('the rung the user picked is the rung that goes out', () => {expect(bodyOf(spy, 0).reasoning_effort).toBe('max')})+ it("a wish off the ladder falls back to the model's own default", async () => {+ const spy = vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(ok())+ await new OpenAIProvider(makeConfig()).chatWithTools(+ 'e-fallback', [{ role: 'user', content: 'hi' }], [],+ { thinking: true, reasoningEffort: 'high', effortLevels: ['low', 'medium', 'max'], effortDefault: 'low' },+ )+ expect(bodyOf(spy, 0).reasoning_effort).toBe('low')+ })++ it('but a model default ABOVE the wish never upgrades the bill', async () => {+ const spy = vi.spyOn(globalThis, 'fetch').mockResolvedValueOnce(ok())+ await new OpenAIProvider(makeConfig()).chatWithTools(+ 'e-fallback-up', [{ role: 'user', content: 'hi' }], [],+ { thinking: true, reasoningEffort: 'low', effortLevels: ['medium', 'high', 'max'], effortDefault: 'max' },+ )+ expect(bodyOf(spy, 0).reasoning_effort).toBe('medium')+ })+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(diff --git a/src/api/providers/openai-provider.ts b/src/api/providers/openai-provider.tsindex 4d5fc7a5..69b0907a 100644--- a/src/api/providers/openai-provider.ts+++ b/src/api/providers/openai-provider.ts@@ -317,7 +317,7 @@ export class OpenAIProvider implements ProviderClient {// up to seven posts for one message, and leave a downgrade in the memory// that nothing ever clears.const wanted = ladder- ? clampEffort(levels, options?.reasoningEffort ?? DEFAULT_EFFORT)+ ? clampEffort(levels, options?.reasoningEffort ?? DEFAULT_EFFORT, options?.effortDefault): DEFAULT_EFFORTconst walked = OpenAIProvider.effortMemory.get(this.effortKey(model, 'on', wanted))return walked?.on === 'omit' ? undefined : wanteddiff --git a/src/api/providers/types.ts b/src/api/providers/types.tsindex c5f7e06b..68bdb8e4 100644--- a/src/api/providers/types.ts+++ b/src/api/providers/types.ts@@ -158,10 +158,16 @@ export interface ChatOptions {/*** 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.+ * them; the provider clamps the wish onto them. Absent = no ladder = old+ * behaviour.*/effortLevels?: string[]+ /**+ * The rung the MODEL declares as its own default. Consulted only where the+ * wish is off the ladder, and only downward: the user's wish is the wish, and+ * a model default above it would quietly upgrade the bill.+ */+ effortDefault?: 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. Whendiff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsxindex 607a0c3a..d01f91a8 100644--- a/src/components/chat/ChatInput.tsx+++ b/src/components/chat/ChatInput.tsx@@ -103,7 +103,7 @@ export function ChatInput({ onSend, onStop, isGenerating, pendingApproval, onAppconst effortLevels = activeModelMeta && 'effortLevels' in activeModelMeta ? activeModelMeta.effortLevels : undefinedconst effortDefault = activeModelMeta && 'effortDefault' in activeModelMeta ? activeModelMeta.effortDefault : undefinedconst effortSteps = effortChoices(effortLevels)- const effortNow = clampEffort(effortLevels, reasoningEffort ?? effortDefault ?? DEFAULT_EFFORT)+ const effortNow = clampEffort(effortLevels, reasoningEffort ?? DEFAULT_EFFORT, effortDefault)// Only while thinking is really happening. 'always' models keep their Think// button locked on, so the rung is live there without the button being.const thinkingIsOn = thinkLockedOn || (thinkingEnabled && canThink)diff --git a/src/hooks/useAgentChat.ts b/src/hooks/useAgentChat.tsindex 0c0267d0..44d9d4a6 100644--- a/src/hooks/useAgentChat.ts+++ b/src/hooks/useAgentChat.ts@@ -792,8 +792,9 @@ export function useAgentChat() {maxTokens: settings.maxTokens || undefined,contextWindow: agentCtx,thinking: thinkOpt as unknown as boolean,- reasoningEffort: settings.reasoningEffort ?? agentEffortDefault,+ reasoningEffort: settings.reasoningEffort,effortLevels: agentEffortLevels,+ effortDefault: agentEffortDefault,signal: abort.signal,}diff --git a/src/hooks/useChat.ts b/src/hooks/useChat.tsindex 03772abd..411cfbb7 100644--- a/src/hooks/useChat.ts+++ b/src/hooks/useChat.ts@@ -689,8 +689,9 @@ export function useChat() {// The rung, and the rungs this model has. Sent on every turn so Chat,// Agent mode and the Coding Agent cannot drift apart; the provider// clamps the wish onto the ladder and ignores both without one.- reasoningEffort: settings.reasoningEffort ?? effortDefault,+ reasoningEffort: settings.reasoningEffort,effortLevels,+ effortDefault,signal: abort.signal,}diff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.tsindex e842de89..3de1d6be 100644--- a/src/hooks/useCodex.ts+++ b/src/hooks/useCodex.ts@@ -977,8 +977,9 @@ export function useCodex() {thinking: thinkOptCx as unknown as boolean,// The Coding Agent is the third caller that builds its own options,// and the one where a forgotten field costs the most tokens.- reasoningEffort: settings.reasoningEffort ?? cxEffort.fallback,+ reasoningEffort: settings.reasoningEffort,effortLevels: cxEffort.levels,+ effortDefault: cxEffort.fallback,signal: abort.signal,}// Hoisted to the top of the step (2.6.7 Denk-Audit): the promptdiff --git a/src/lib/__tests__/effort.test.ts b/src/lib/__tests__/effort.test.tsindex 8f85d9cc..0123f0f0 100644--- a/src/lib/__tests__/effort.test.ts+++ b/src/lib/__tests__/effort.test.ts@@ -73,6 +73,42 @@ describe('clamping the wish onto the rungs a model really has', () => {})})+describe("the model's own default is the fallback, and only downward", () => {+ // The global setting is the user's wish. The model's declared default is+ // consulted where the wish is off the ladder, because at that point the+ // model knows better than our arithmetic does.+ it('a wish off the ladder lands on the model default', () => {+ expect(clampEffort(['low', 'medium', 'max'], 'high', 'low')).toBe('low')+ })++ it('THE GUARD: a default above the wish is ignored, it would upgrade the bill', () => {+ // Ladder without 'low', user asked for 'low', model says 'max'. Honouring+ // the default here would charge a user who asked for the cheapest rung the+ // most expensive one, silently.+ expect(clampEffort(['medium', 'high', 'max'], 'low', 'max')).toBe('medium')+ expect(clampEffort(['medium', 'high', 'max'], 'low', 'max')).not.toBe('max')+ })++ it('a default that is not on the ladder is no help and is skipped', () => {+ expect(clampEffort(['low', 'medium'], 'max', 'high')).toBe('medium')+ expect(clampEffort(['low', 'medium'], 'max', 'nonsense')).toBe('medium')+ })++ it('a wish ON the ladder is never overruled by the default', () => {+ expect(clampEffort(['low', 'medium', 'high'], 'low', 'high')).toBe('low')+ })++ it('and an unknown wish takes the default before it takes ours', () => {+ expect(clampEffort(['low', 'medium', 'high'], 'ludicrous', 'low')).toBe('low')+ expect(clampEffort(['low', 'medium', 'high'], 'ludicrous')).toBe('high')+ })++ it('no fallback at all behaves exactly as before', () => {+ expect(clampEffort(MOST, 'max')).toBe('high')+ expect(clampEffort(['medium', 'high'], 'low')).toBe('medium')+ })+})+describe('no ladder means no change', () => {it('an absent ladder answers with the rung this client has always sent', () => {expect(clampEffort(undefined, 'low')).toBe('high')diff --git a/src/lib/__tests__/thinking-side-surfaces.test.ts b/src/lib/__tests__/thinking-side-surfaces.test.tsindex f8e89900..31070864 100644--- a/src/lib/__tests__/thinking-side-surfaces.test.ts+++ b/src/lib/__tests__/thinking-side-surfaces.test.ts@@ -167,23 +167,27 @@ describe('the effort rung reaches every surface, not only chat', () => {const codex = read('../../hooks/useCodex.ts')it('chat sends the rung and the ladder', () => {- expect(chat).toContain('reasoningEffort: settings.reasoningEffort ?? effortDefault')+ expect(chat).toContain('reasoningEffort: settings.reasoningEffort,')expect(chat).toMatch(/^\s*effortLevels,$/m)+ expect(chat).toMatch(/^\s*effortDefault,$/m)})it('agent mode sends them too', () => {- expect(agent).toContain('reasoningEffort: settings.reasoningEffort ?? agentEffortDefault')+ expect(agent).toContain('reasoningEffort: settings.reasoningEffort,')expect(agent).toContain('effortLevels: agentEffortLevels')+ expect(agent).toContain('effortDefault: agentEffortDefault')})it('and the coding agent, the surface with the largest token bill', () => {- expect(codex).toContain('reasoningEffort: settings.reasoningEffort ?? cxEffort.fallback')+ expect(codex).toContain('reasoningEffort: settings.reasoningEffort,')expect(codex).toContain('effortLevels: cxEffort.levels')+ expect(codex).toContain('effortDefault: cxEffort.fallback')})it('all three read the ladder off the model row the server filled in', () => {for (const src of [chat, agent, codex]) {expect(src).toMatch(/'effortLevels' in \w+ \? \w+\.effortLevels : undefined/)+ expect(src).toMatch(/'effortDefault' in \w+ \? \w+\.effortDefault : undefined/)}})})diff --git a/src/lib/effort.ts b/src/lib/effort.tsindex 3d491942..61a95e81 100644--- a/src/lib/effort.ts+++ b/src/lib/effort.ts@@ -71,16 +71,32 @@ export function effortChoices(levels: readonly string[] | undefined): EffortLeve/*** The wish, clamped onto the rungs this model really has.*- * Down before up: a wish above the model's top rung becomes that top rung- * (asking Qwen3.8 27B for 'max' would 400), and only a wish below the cheapest- * rung is rounded up. No ladder at all returns DEFAULT_EFFORT, which is what- * the client sent before any of this existed.+ * Who decides what: the global setting is the USER'S wish and always wins where+ * the model can honour it. `fallback` is the model's own declared default+ * (`reasoning_effort_default`) and is consulted only where the wish is off the+ * ladder, because at that point the model's opinion is better than our+ * arithmetic. It can only ever make the request CHEAPER: a fallback above the+ * wish is ignored, or a model declaring `max` would quietly upgrade a user who+ * asked for `low` and hand them the bill.+ *+ * Down before up otherwise: a wish above the model's top rung becomes that top+ * rung, and only a wish below the cheapest rung is rounded up. No ladder at all+ * returns DEFAULT_EFFORT, which is what the client sent before any of this+ * existed.*/-export function clampEffort(levels: readonly string[] | undefined, wanted: string): string {+export function clampEffort(+ levels: readonly string[] | undefined,+ wanted: string,+ fallback?: string,+): string {const ladder = known(levels)if (ladder.length === 0) return DEFAULT_EFFORTif (ladder.includes(wanted)) return wantedconst rank = RANK[wanted]+ // The model's own default, but never as an upgrade.+ if (fallback && ladder.includes(fallback) && (rank === undefined || RANK[fallback] <= rank)) {+ return fallback+ }// A word we do not know is treated as the default wish, never as "the most// the model can do": on GLM 5.3 an invalid value silently means max, and// guessing upward is the one guess the customer pays for.