Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(claude): honor Cindy model selection over stale allowlist (#2285)

mengfanyu9410-hub39a23511011d
diff --git a/packages/maker-core/src/agents/claude-code/__tests__/flag-settings.test.ts b/packages/maker-core/src/agents/claude-code/__tests__/flag-settings.test.ts
index 6c43077f3c..41dae428a9 100644
--- a/packages/maker-core/src/agents/claude-code/__tests__/flag-settings.test.ts
+++ b/packages/maker-core/src/agents/claude-code/__tests__/flag-settings.test.ts
@@ -51,6 +51,16 @@ describe('buildClaudeFlagSettings', () => {
).toBe(false);
});
+ it('uses host-provided Claude SDK wire models over a user availableModels allowlist', () => {
+ const settings = buildClaudeFlagSettings({
+ showThinkingSummaries: false,
+ fastMode: false,
+ availableModels: ['claude-opus-4-6[1m]', 'claude-sonnet-5'],
+ });
+
+ expect(settings.availableModels).toEqual(['claude-opus-4-6[1m]', 'claude-sonnet-5']);
+ });
+
it('adds namespaced plugin skill overrides from the host routing policy', () => {
const settings = buildClaudeFlagSettings({
showThinkingSummaries: false,
diff --git a/packages/maker-core/src/agents/claude-code/__tests__/rewind-runtime-settings.test.ts b/packages/maker-core/src/agents/claude-code/__tests__/rewind-runtime-settings.test.ts
index f81f2fd88d..33aa0577b1 100644
--- a/packages/maker-core/src/agents/claude-code/__tests__/rewind-runtime-settings.test.ts
+++ b/packages/maker-core/src/agents/claude-code/__tests__/rewind-runtime-settings.test.ts
@@ -237,6 +237,23 @@ afterEach(async () => {
});
describe('ClaudeCodeAgent runtime settings during rewind window', () => {
+ it('keeps the selected and catalog Claude wire models available for a live model switch', async () => {
+ const { handle, firstQuery } = await startRewindableSession();
+
+ const startArgs = sdkMock.query.mock.calls[0]?.[0] as {
+ options: { settings?: { availableModels?: string[] } };
+ };
+ expect(startArgs.options.settings?.availableModels).toEqual([
+ 'claude-opus-4-6[1m]',
+ 'claude-sonnet-5',
+ ]);
+
+ await handle.setModel?.('claude-sonnet-5');
+ expect(firstQuery.setModel).toHaveBeenCalledWith('claude-sonnet-5');
+
+ await handle.close();
+ });
+
it('passes max through when changing effort in a live Sonnet 5 session', async () => {
const { handle, firstQuery } = await startRewindableSession();
diff --git a/packages/maker-core/src/agents/claude-code/flag-settings.ts b/packages/maker-core/src/agents/claude-code/flag-settings.ts
index afd62dc1b5..5fe53d10dc 100644
--- a/packages/maker-core/src/agents/claude-code/flag-settings.ts
+++ b/packages/maker-core/src/agents/claude-code/flag-settings.ts
@@ -47,6 +47,11 @@ export interface ClaudeFlagSettingsInput {
fastMode: boolean;
/** Host-owned policy for colliding downstream skills. */
capabilityRouting?: CapabilityRoutingPolicy;
+ /**
+ * Final Claude SDK wire model strings that Cindy allows for this session.
+ * This highest-priority list replaces any stale user availableModels list.
+ */
+ availableModels?: readonly string[];
}
/** 装配 startSession 注入的 flag settings 对象。纯函数 —— 每次调用读最新输入值。 */
@@ -61,6 +66,9 @@ export function buildClaudeFlagSettings(input: ClaudeFlagSettingsInput): Setting
autoDreamEnabled: input.memoryOverride,
}),
...(input.fastMode && { fastMode: true }),
+ ...(input.availableModels && input.availableModels.length > 0 && {
+ availableModels: [...new Set(input.availableModels)],
+ }),
...(Object.keys(skillOverrides).length > 0 && { skillOverrides }),
};
}
diff --git a/packages/maker-core/src/agents/claude-code/index.ts b/packages/maker-core/src/agents/claude-code/index.ts
index b8ced99234..9d1d8e9583 100644
--- a/packages/maker-core/src/agents/claude-code/index.ts
+++ b/packages/maker-core/src/agents/claude-code/index.ts
@@ -1763,6 +1763,17 @@ export class ClaudeCodeAgent extends BaseAgent {
const buildSettings = (): Settings =>
buildClaudeFlagSettings({
showThinkingSummaries,
+ // availableModels is the SDK's highest-priority allowlist. Convert the
+ // whole current catalog and the selected model through the one
+ // catalog-id → wire-string mapper so startup and live switches share
+ // the same [1m] and legacy conversion rules. Keep the selected model
+ // even when it is temporarily outside the catalog.
+ availableModels: [
+ ...new Set([
+ ...this.capabilities.availableModels.map(({ id }) => sdkModelFor(id)),
+ sdkModelFor(mutableModel),
+ ]),
+ ],
// Do not carry the local manager's native-memory suppression across the
// SSH boundary: the remote host retains its own Claude memory
// configuration. Maker Memory on remote sessions is injected via the