Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
14673c7
fix(web-shell): persist model reasoning preferences
callmeYe Aug 29, 2026
6a9bf19
fix(web-shell): retain reasoning preview for new tasks
callmeYe Aug 29, 2026
4885a6b
fix(web-shell): ignore stale reasoning provider snapshots
callmeYe Aug 29, 2026
41beaa6
Merge remote-tracking branch 'origin/main' into codex/fix-webshell-re…
callmeYe Aug 29, 2026
7ac6790
Merge remote-tracking branch 'origin/main' into codex/fix-webshell-re…
wenshao Aug 29, 2026
b5f5359
fix(web-shell): harden reasoning preference persistence
callmeYe Aug 30, 2026
a1b2513
fix(web-shell): correct daemon SDK test import
callmeYe Aug 30, 2026
9c63c7f
Merge remote-tracking branch 'origin/main' into codex/fix-webshell-re…
callmeYe Aug 30, 2026
0c456eb
Merge branch 'main' into codex/fix-webshell-reasoning-preferences
wenshao Aug 30, 2026
d9cf27f
Merge branch 'main' into codex/fix-webshell-reasoning-preferences
qwen-code-dev-bot Aug 31, 2026
049e911
fix(web-shell): preserve reasoning across scoped session transitions
callmeYe Aug 31, 2026
bedaf5e
Merge remote-tracking branch 'origin/codex/fix-webshell-reasoning-pre…
callmeYe Aug 31, 2026
41630dd
Merge remote-tracking branch 'origin/main' into codex/fix-webshell-re…
callmeYe Aug 31, 2026
17e56a5
Merge remote-tracking branch 'origin/main' into codex/fix-webshell-re…
callmeYe Aug 31, 2026
0f9d98b
Merge remote-tracking branch 'origin/main' into codex/fix-webshell-re…
callmeYe Aug 31, 2026
a4664e9
refactor(web-shell): consolidate reasoning preferences and tests
callmeYe Aug 31, 2026
175f524
test(serve): complete workspace facade reasoning mock
callmeYe Aug 31, 2026
80399bc
fix(web-shell): retain reasoning preferences across auth refresh
callmeYe Aug 31, 2026
26f5826
fix(web-shell): honor reasoning preferences after model reload
callmeYe Aug 31, 2026
896e360
fix(web-shell): retain session reasoning across rebuilds
callmeYe Sep 1, 2026
3eebaea
fix(web-shell): reconcile reasoning settings reloads
callmeYe Sep 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions docs/design/webshell-reasoning-preferences.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# WebShell model reasoning preferences

## Goal

WebShell keeps the selected model and reasoning preference across daemon
sessions without creating an empty session from the Welcome screen. The first
prompt remains the session-creation boundary.

This change uses the existing `model.reasoningEffort` setting. It does not add
a second reasoning-enabled setting and does not change provider request
mapping or the public ACP protocol.

## Stored values

`model.reasoningEffort` has one meaning at every daemon boundary:

- an absent value uses the target model's default thinking behavior;
- `none` disables thinking;
- `low`, `medium`, `high`, `xhigh`, or `max` enables thinking at that tier.

`default` is a control command only. It removes the stored value and resets the
live session to the model default. It is never stored and is never rendered as
an effort choice.

The Core `ReasoningEffort` type remains the five strict tiers. `none` and
`default` are represented only by the daemon and settings boundary type.

## Session lifecycle

Before a session exists, WebShell keeps the selected model and reasoning value
in component state. Sending the first prompt performs these operations in
order: create, attach, set model, persist reasoning, then submit the prompt.

For a live session, WebShell sends reasoning changes immediately with
`persist: true`. It updates its state only from the daemon's confirmed
`configOptions` response. The daemon writes the setting and live state before
returning success.

Turning thinking off sends `none`. Turning it on again sends `default`, which
removes `none` and uses the model default instead of restoring the old tier.

## Capability reconciliation

Every model switch reconciles the stored selection against the target model:

- a supported tier and an allowed `none` value are retained;
- an unsupported tier is removed and the live override is reset;
- a toggle-only model retains only `none` when disabling is allowed;
- a model without reasoning controls removes every explicit selection;
- mandatory thinking removes `none`.

There is no fallback or tier clamping at this layer. Once an incompatible
selection is removed, switching back does not restore it.

Welcome uses model-specific workspace previews. Once a session exists,
WebShell renders reasoning controls only from that session's authoritative
`configOptions`.

## UI and localization

Tiered models render only the real advertised tiers. Toggle-only models render
only the thinking switch: no effort heading, effort row, or Default choice is
present in the DOM. Unsupported models render no reasoning section.

WebShell translates the five fixed effort values itself in English and Chinese
and never renders daemon-provided English labels.
211 changes: 191 additions & 20 deletions packages/cli/src/acp-integration/acpAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2078,6 +2078,7 @@ describe('QwenAgent MCP SSE/HTTP support', () => {
getRewindableUserTurnCount: ReturnType<typeof vi.fn>;
clearActiveTodoPlanRevision: ReturnType<typeof vi.fn>;
clearTodoStopGuardTrust: ReturnType<typeof vi.fn>;
persistReasoningSelection: ReturnType<typeof vi.fn>;
hardSuspendTodoStopGuard: ReturnType<typeof vi.fn>;
beginClose: ReturnType<typeof vi.fn>;
beginCloseIfAvailable: ReturnType<typeof vi.fn>;
Expand Down Expand Up @@ -4500,6 +4501,7 @@ describe('QwenAgent MCP SSE/HTTP support', () => {
getRewindableUserTurnCount: vi.fn().mockReturnValue(1),
clearActiveTodoPlanRevision: vi.fn(),
clearTodoStopGuardTrust: vi.fn(),
persistReasoningSelection: vi.fn().mockReturnValue(true),
hardSuspendTodoStopGuard: vi.fn(),
releaseTodoStopGuardQueuedPromptWait: vi.fn().mockReturnValue(true),
isIdle: vi.fn().mockReturnValue(true),
Expand Down Expand Up @@ -8317,6 +8319,7 @@ describe('QwenAgent MCP SSE/HTTP support', () => {
category: 'thought_level',
currentValue: 'default',
options: [
{ value: 'none', name: 'Thinking off' },
{ value: 'default', name: 'Default' },
{ value: 'low', name: 'Low', description: expect.any(String) },
{ value: 'medium', name: 'Medium', description: expect.any(String) },
Expand Down Expand Up @@ -8362,7 +8365,7 @@ describe('QwenAgent MCP SSE/HTTP support', () => {
value: 'ultra',
}),
).rejects.toThrow(
'Unknown reasoning effort: ultra. Choose one of: default, low, medium, high, xhigh, max',
'Unknown reasoning effort: ultra. Choose one of: default, none, low, medium, high, xhigh, max',
);
expect(innerConfig.setReasoningEffort).toHaveBeenCalledTimes(2);

Expand All @@ -8383,6 +8386,73 @@ describe('QwenAgent MCP SSE/HTTP support', () => {
}
});

it('does not re-enable an explicitly disabled generic model with a tier', async () => {
const sessionId = 'generic-disabled-reasoning-session';
const innerConfig = await setupSessionMocks(sessionId);
const generation: {
reasoning?: false | { effort?: string };
} = { reasoning: false };
innerConfig.getModel = vi.fn().mockReturnValue('claude-opus-4-6');
innerConfig.getContentGeneratorConfig = vi.fn(() => generation);
innerConfig.getReasoningEffort = vi.fn(() =>
generation.reasoning ? generation.reasoning.effort : undefined,
);
innerConfig.setReasoningEffort = vi.fn((effort: string | undefined) => {
if (generation.reasoning === false) return;
generation.reasoning = effort ? { effort } : undefined;
});

const { agent, agentPromise } = await bootAcpAgent();
try {
await agent.newSession({ cwd: '/tmp', mcpServers: [] });

await expect(
agent.setSessionConfigOption({
sessionId,
configId: 'reasoning_effort',
value: 'high',
_meta: { 'qwenCode/persistReasoningSelection': true },
}),
).rejects.toThrow(
'Reasoning effort cannot be applied while thinking is disabled',
);
expect(generation.reasoning).toBe(false);
expect(lastSessionMock?.persistReasoningSelection).not.toHaveBeenCalled();
} finally {
mockConnectionState.resolve();
await agentPromise;
}
});

it('replays a persisted thinking disable after daemon authentication', async () => {
const sessionId = 'persisted-none-auth-session';
const innerConfig = await setupSessionMocks(sessionId);
const generation: {
model: string;
reasoning?: false | { effort?: string };
} = { model: 'claude-opus-4-6', reasoning: false };
const settings = makeSessionSettings({
mcpServers: {},
model: { reasoningEffort: 'none' },
});
vi.mocked(loadSettings).mockReturnValue(settings);
innerConfig.getModel = vi.fn(() => generation.model);
innerConfig.getContentGeneratorConfig = vi.fn(() => generation);
innerConfig.refreshAuth = vi.fn(async () => {
generation.reasoning = undefined;
});

const { agent, agentPromise } = await bootAcpAgent();
try {
await agent.newSession({ cwd: '/tmp', mcpServers: [] });

expect(generation.reasoning).toBe(false);
} finally {
mockConnectionState.resolve();
await agentPromise;
}
});

it('projects qwen3.8-max reasoning controls through one ACP option', async () => {
const sessionId = 'qwen38-reasoning-session';
const innerConfig = await setupSessionMocks(sessionId);
Expand Down Expand Up @@ -8430,7 +8500,14 @@ describe('QwenAgent MCP SSE/HTTP support', () => {
sessionId,
configId: 'reasoning_effort',
value: 'medium',
_meta: { 'qwenCode/persistReasoningSelection': true },
})) as SetSessionConfigOptionResponse;
expect(lastSessionMock?.persistReasoningSelection).toHaveBeenCalledWith(
'medium',
);
expect(medium._meta).toEqual({
'qwenCode/reasoningSelectionPersisted': true,
});
expect(generation.reasoning).toEqual({ effort: 'medium' });
expect(
medium.configOptions.find((item) => item.id === 'reasoning_effort')
Expand Down Expand Up @@ -8459,6 +8536,21 @@ describe('QwenAgent MCP SSE/HTTP support', () => {
?.currentValue,
).toBe('medium');

const reset = (await agent.setSessionConfigOption({
sessionId,
configId: 'reasoning_effort',
value: 'default',
_meta: { 'qwenCode/persistReasoningSelection': true },
})) as SetSessionConfigOptionResponse;
expect(
lastSessionMock?.persistReasoningSelection,
).toHaveBeenLastCalledWith('default');
expect(generation.reasoning).toBeUndefined();
expect(
reset.configOptions.find((item) => item.id === 'reasoning_effort')
?.currentValue,
).toBe('xhigh');

await expect(
agent.setSessionConfigOption({
sessionId,
Expand All @@ -8468,7 +8560,7 @@ describe('QwenAgent MCP SSE/HTTP support', () => {
).rejects.toThrow(
'Unknown reasoning effort: high. Choose one of: none, low, medium, xhigh',
);
Comment thread
callmeYe marked this conversation as resolved.
Resolved
expect(generation.reasoning).toEqual({ effort: 'medium' });
expect(generation.reasoning).toBeUndefined();
} finally {
mockConnectionState.resolve();
await agentPromise;
Expand Down Expand Up @@ -8652,6 +8744,64 @@ describe('QwenAgent MCP SSE/HTTP support', () => {
}
});

it('returns qwen3.8-max to default after a static thinking disable', async () => {
const sessionId = 'qwen38-static-thinking-default';
const innerConfig = await setupSessionMocks(sessionId);
const generation: {
reasoning?: false | { effort?: string };
extra_body?: Record<string, unknown>;
samplingParams?: Record<string, unknown>;
} = {
reasoning: { effort: 'low' },
extra_body: { enable_thinking: false, seed: 7 },
samplingParams: { thinking_budget: 2048, temperature: 0.2 },
};
innerConfig.getModel = vi.fn().mockReturnValue('qwen3.8-max');
innerConfig.getContentGeneratorConfig = vi.fn(() => generation);
innerConfig.getReasoningEffort = vi.fn(() =>
generation.reasoning ? generation.reasoning.effort : undefined,
);
innerConfig.getReasoningEffortOverride = vi.fn(() =>
generation.extra_body?.['enable_thinking'] === false
? {
source: 'extra_body' as const,
field: 'enable_thinking' as const,
}
: generation.samplingParams?.['thinking_budget'] !== undefined
? {
source: 'samplingParams' as const,
field: 'thinking_budget' as const,
}
: undefined,
);

const { agent, agentPromise } = await bootAcpAgent();
try {
await agent.newSession({ cwd: '/tmp', mcpServers: [] });

const reset = (await agent.setSessionConfigOption({
sessionId,
configId: 'reasoning_effort',
value: 'default',
_meta: { 'qwenCode/persistReasoningSelection': true },
})) as SetSessionConfigOptionResponse;

expect(generation.extra_body).toEqual({ seed: 7 });
expect(generation.samplingParams).toEqual({ temperature: 0.2 });
expect(generation.reasoning).toBeUndefined();
expect(
reset.configOptions.find((item) => item.id === 'reasoning_effort')
?.currentValue,
).toBe('xhigh');
expect(
lastSessionMock?.persistReasoningSelection,
).toHaveBeenLastCalledWith('default');
} finally {
mockConnectionState.resolve();
await agentPromise;
}
});

it.each([
[4096, 'low'],
[4097, 'medium'],
Expand Down Expand Up @@ -8695,7 +8845,36 @@ describe('QwenAgent MCP SSE/HTTP support', () => {
},
);

it('does not project qwen3.8 controls onto an opaque model route', async () => {
it('does not guess reasoning capabilities for an unregistered Qwen model', async () => {
const sessionId = 'unregistered-qwen-reasoning';
const innerConfig = await setupSessionMocks(sessionId);
innerConfig.getModel = vi.fn().mockReturnValue('qwen-plus');

const { agent, agentPromise } = await bootAcpAgent();
try {
const session = (await agent.newSession({
cwd: '/tmp',
mcpServers: [],
})) as SetSessionConfigOptionResponse;
expect(
session.configOptions.find((item) => item.id === 'reasoning_effort'),
).toBeUndefined();

await expect(
agent.setSessionConfigOption({
sessionId,
configId: 'reasoning_effort',
value: 'high',
}),
).rejects.toThrow('Reasoning is not supported by the current model');
expect(innerConfig.setReasoningEffort).not.toHaveBeenCalled();
} finally {
mockConnectionState.resolve();
await agentPromise;
}
});

it('does not expose reasoning controls on an opaque model route', async () => {
const sessionId = 'qwen38-opaque-route-reasoning';
const innerConfig = await setupSessionMocks(sessionId);
let currentEffort: string | undefined;
Expand Down Expand Up @@ -8736,24 +8915,16 @@ describe('QwenAgent MCP SSE/HTTP support', () => {
).toMatch(/^qwen-route:v1:/);
expect(
session.configOptions.find((item) => item.id === 'reasoning_effort'),
).toMatchObject({
currentValue: 'default',
options: [
{ value: 'default' },
{ value: 'low' },
{ value: 'medium' },
{ value: 'high' },
{ value: 'xhigh' },
{ value: 'max' },
],
});
).toBeUndefined();

await agent.setSessionConfigOption({
sessionId,
configId: 'reasoning_effort',
value: 'medium',
});
expect(innerConfig.setReasoningEffort).toHaveBeenCalledWith('medium');
await expect(
agent.setSessionConfigOption({
sessionId,
configId: 'reasoning_effort',
value: 'medium',
}),
).rejects.toThrow('Reasoning is not supported by the current model');
expect(innerConfig.setReasoningEffort).not.toHaveBeenCalled();
} finally {
mockConnectionState.resolve();
await agentPromise;
Expand Down
Loading
Loading