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(desktop): complete scheduled route admission and permanent selection lifecycle

ylliuuu66c2f3730db4e1
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botModelRouteReconciler.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botModelRouteReconciler.test.ts
index 812ace0933..9201182d27 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/botModelRouteReconciler.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/botModelRouteReconciler.test.ts
@@ -1,5 +1,6 @@
import { describe, expect, it, vi } from 'vitest';
import { withSendToSessionLock } from '../sendToSessionLock';
+import { createScheduledModelScope } from '../scheduledModelSelection';
import { createBotModelRouteReconciler } from '../botModelRouteReconciler';
import type { BotModelRoute } from '../../../shared/botModelChain';
import type { SessionRuntimeProfile } from '../sessionRuntimeControl';
@@ -13,8 +14,9 @@ function harness() {
};
const read = vi.fn(async () => state);
const apply = vi.fn<Parameters<typeof createBotModelRouteReconciler>[0]['apply']>(async () => undefined);
- const reconcile = createBotModelRouteReconciler({ ownerEpoch: () => owner, read, apply });
- return { state, read, apply, reconcile, changeOwner: () => { owner = 'owner-b'; } };
+ const onSelectionAccepted = vi.fn(async (_id: string) => {});
+ const reconcile = createBotModelRouteReconciler({ ownerEpoch: () => owner, read, apply, onSelectionAccepted });
+ return { state, read, apply, reconcile, onSelectionAccepted, changeOwner: () => { owner = 'owner-b'; } };
}
describe('permanent Bot model selection', () => {
@@ -232,3 +234,35 @@ it('reconciles shared-to-local and local-to-shared selections of the same model'
await h.reconcile.profileChanged('canonical');
expect(h.apply).toHaveBeenLastCalledWith('canonical', local, h.state.current);
});
+
+// #6759: an explicit save can accept the automation's temporary model without a switch.
+it.each([true, false])('invalidates the automation baseline after an explicit save (already current: %s)', async alreadyCurrent => {
+ const h = harness();
+ const permanent = { agentKind: 'codex' as const, model: 'luna', providerId: 'xd', effort: 'medium' as const, fastMode: false };
+ h.state.current = alreadyCurrent ? permanent : { ...permanent, model: 'temporary-model' };
+ h.apply.mockImplementation(async () => { h.state.current = permanent; });
+ let baseline: string | null = JSON.stringify({ ...permanent, model: 'old-model', scopeId: 'automation' });
+ const scope = createScheduledModelScope({
+ read: async () => ({ profile: h.state.current, baseline }),
+ write: async (_id, value) => { baseline = value ? JSON.stringify(value) : null; },
+ apply: async (_id, profile) => { h.state.current = profile; },
+ isBusy: () => false, createId: () => 'unused',
+ });
+ h.onSelectionAccepted.mockImplementation(async () => { baseline = null; });
+ if (alreadyCurrent) {
+ await h.reconcile('canonical');
+ expect(baseline).not.toBeNull(); // Ordinary reconciliation must not cancel an automation scope.
+ }
+ await h.reconcile.profileChanged('canonical');
+ await scope.restore('canonical', 'automation');
+ expect(h.state.current).toEqual(permanent);
+ expect(baseline).toBeNull();
+ expect(h.apply).toHaveBeenCalledTimes(alreadyCurrent ? 0 : 1);
+});
+
+it('does not accept a permanent selection whose staging failed', async () => {
+ const h = harness();
+ h.apply.mockRejectedValueOnce(new Error('provider unavailable'));
+ await expect(h.reconcile.profileChanged('canonical')).rejects.toThrow('provider unavailable');
+ expect(h.onSelectionAccepted).not.toHaveBeenCalled();
+});
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/scheduledModelRemoteRoute.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/scheduledModelRemoteRoute.test.ts
index 7dc3ac0baf..9e7dc8bce6 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/scheduledModelRemoteRoute.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/scheduledModelRemoteRoute.test.ts
@@ -1,29 +1,9 @@
-import { readFileSync } from 'node:fs';
-import ts from 'typescript';
import { describe, expect, it, vi } from 'vitest';
import type { ProviderView } from '@cindy/model-providers';
-import { applyScheduledModelSelection, createScheduledModelScope, resolveScheduledModelSelection, type ScheduledModelSelection } from '../scheduledModelSelection';
+import { applyScheduledModelSelection, createScheduledModelScope, createScheduledModelSelectionResolver, resolveScheduledModelSelection, type ScheduledModelSelection } from '../scheduledModelSelection';
-// #6745: execute the production adapter and persisted-scope restore together.
-// A shared-provider baseline must use the execution computer's catalog.
-const source = ts.createSourceFile('register.ts', readFileSync(new URL('../register.ts', import.meta.url), 'utf8'), ts.ScriptTarget.Latest, true);
-const adapters = new Map<string, string>();
-function visit(node: ts.Node) {
- if (ts.isVariableDeclaration(node) && node.initializer) {
- if (node.name.getText(source) === 'applyScheduledProfile') adapters.set('scheduled', node.initializer.getText(source));
- if (node.name.getText(source) === 'reconcileBotModelRoute' && ts.isCallExpression(node.initializer)) {
- const deps = node.initializer.arguments[0] as ts.ObjectLiteralExpression;
- const apply = deps.properties.find(p => ts.isPropertyAssignment(p) && p.name.getText(source) === 'apply') as ts.PropertyAssignment;
- adapters.set('bot', apply.initializer.getText(source));
- }
- }
- ts.forEachChild(node, visit);
-}
-visit(source);
-function compile(key: string, bindings: Record<string, unknown>) {
- const js = ts.transpileModule(`return ${adapters.get(key)};`, { compilerOptions: { target: ts.ScriptTarget.ES2022 } }).outputText;
- return new Function(...Object.keys(bindings), js)(...Object.values(bindings));
-}
+// #6745: invoke the same production resolver wired into register.ts with the
+// real persisted-scope lifecycle; only catalog, storage and engine I/O are fakes.
const choice: ScheduledModelSelection = {
agentKind: 'codex', model: 'test-model', providerId: 'openai-shared', effort: 'high', fastMode: false,
};
@@ -41,33 +21,29 @@ function fixture(device: string | null = 'share:test', status = 'active') {
if (!local.some(p => p.id === providerId)) throw new Error('provider unavailable on this computer');
return undefined;
});
- const query = { from: () => query, where: () => query, limit: async () => [{ planMode: false }] };
- const switchHarness = vi.fn(async (_deps: unknown, route: { agentDeviceId?: string | null }) => {
- if (route.agentDeviceId !== undefined) current.agentDeviceId = route.agentDeviceId;
- return { engineReady: true };
+ const switchHarness = vi.fn(async () => ({ engineReady: true }));
+ const applyModel = vi.fn(async (route: ScheduledModelSelection) => {
+ current = { ...current, ...route };
});
- const applyModel = vi.fn(async (_id: string, model: string, providerId: string | null, axes: object) => {
- current = { ...current, model, providerId, ...axes };
- return {};
- });
- const apply = compile('scheduled', {
- applyScheduledModelSelection, resolveScheduledModelSelection,
- agentSwitchDeps: { getSessionRow: async () => status === 'missing' ? null : ({ ...current, status }) },
- dbToMakerAgentKind: (kind: string) => kind,
- isSessionInTurn: () => false, maker: { getSession: () => undefined },
- assertModelRouteUsable: guard, shouldApplyExclusiveProviderRerouteLive: () => false,
- resolveScheduledModelSelectionLive: async (route: ScheduledModelSelection) => resolveScheduledModelSelection(route, local),
- readUsableAgentDeviceProviders: remote,
- performSessionAgentSwitch: switchHarness, getDbClient: () => ({ drizzle: { select: () => query } }),
- sessions: {}, eq: vi.fn(), persistSessionFields: vi.fn(),
- applySessionRuntimeSelection: applyModel, runtimeSelectionRequiresModelWindowConfirmation: () => false,
+ const apply = async (_id: string, selection: ScheduledModelSelection) => applyScheduledModelSelection(selection, {
+ getTarget: async () => status === 'missing' ? null : ({ ...current, status }),
+ isBusy: () => false,
+ resolveSelection: createScheduledModelSelectionResolver({
+ readRemoteProviders: remote,
+ resolveLocalSelection: async route => {
+ await guard(route.agentKind, route.model, route.providerId);
+ return resolveScheduledModelSelection(route, local);
+ },
+ }),
+ switchHarness, applyModel,
});
const deps = {
read: async () => ({ profile: current, baseline }),
write: async (_id: string, value: unknown) => { baseline = value ? JSON.stringify(value) : null; },
- isBusy: () => false, createId: () => 'new-run', apply,
+ isBusy: () => false, createId: () => 'new-run',
+ apply: async (id: string, profile: ScheduledModelSelection) => { await apply(id, profile); },
};
- return { deps, remote, guard, switchHarness, applyModel, scope: createScheduledModelScope(deps),
+ return { deps, apply, remote, guard, switchHarness, applyModel, scope: createScheduledModelScope(deps),
state: () => ({ current, baseline }), save: (value: unknown) => { baseline = JSON.stringify(value); } };
}
@@ -83,7 +59,7 @@ describe('automation restore uses the execution computer', () => {
});
it('validates an automation choice on the same remote execution computer', async () => {
const h = fixture();
- await h.deps.apply('task', choice);
+ await h.apply('task', choice);
expect(h.remote).toHaveBeenCalledWith('share:test', 'codex', 'test-model', 'openai-shared');
expect(h.guard).not.toHaveBeenCalled();
expect(h.switchHarness).not.toHaveBeenCalled();
@@ -106,6 +82,31 @@ describe('automation restore uses the execution computer', () => {
expect(h.guard).not.toHaveBeenCalled();
expect(h.state().baseline).not.toBeNull();
});
+ it('preserves the standard admission exception for a custom user-owned model group', async () => {
+ const h = fixture();
+ const views = catalog('openai-shared');
+ const model = 'gpt-4o-audio-preview';
+ views[0].models.codex![0].id = model;
+ views[0].models.codex![0].group = 'custom:openai-shared';
+ h.save({ ...choice, model, scopeId: 'old-run' });
+ h.remote.mockResolvedValueOnce(views);
+ await h.scope.restore('task');
+ expect(h.state().baseline).toBeNull();
+ expect(h.state().current).toMatchObject({ ...choice, model });
+ });
+ it.each([{ status: 'retired' }, { availability: 'requires_payment' }, { mode: 'image' }])(
+ 'rejects a remote catalog entry outside new-route admission: %j', async flags => {
+ const h = fixture();
+ const before = h.state();
+ const views = catalog('openai-shared');
+ Object.assign(views[0].models.codex![0], flags);
+ h.remote.mockResolvedValueOnce(views);
+ await expect(h.scope.restore('task')).rejects.toThrow('unavailable');
+ expect(h.state()).toEqual(before);
+ expect(h.applyModel).not.toHaveBeenCalled();
+ expect(h.switchHarness).not.toHaveBeenCalled();
+ },
+ );
it.each(['provider', 'model'] as const)('preserves the baseline when the remote %s is disabled after restart', async disabled => {
const h = fixture();
const before = h.state();
@@ -124,7 +125,7 @@ describe('automation restore uses the execution computer', () => {
const before = h.state();
h.remote.mockRejectedValue(new Error('REMOTE_AGENT_SHARE_PAUSED'));
const localChoice = { ...choice, providerId: 'openai' };
- await expect(h.deps.apply('task', localChoice)).resolves.toEqual(localChoice);
+ await expect(h.apply('task', localChoice)).resolves.toEqual(localChoice);
expect(h.remote).not.toHaveBeenCalled();
expect(h.guard).toHaveBeenCalledWith('codex', 'test-model', 'openai');
expect(h.applyModel).not.toHaveBeenCalled();
@@ -133,7 +134,7 @@ describe('automation restore uses the execution computer', () => {
});
it.each(['archived', 'deleted'])('rejects a remote-only source for the local replacement of a %s target', async status => {
const h = fixture('share:test', status);
- await expect(h.deps.apply('task', choice)).rejects.toThrow('provider unavailable');
+ await expect(h.apply('task', choice)).rejects.toThrow('provider unavailable');
expect(h.remote).not.toHaveBeenCalled();
expect(h.applyModel).not.toHaveBeenCalled();
expect(h.switchHarness).not.toHaveBeenCalled();
@@ -153,32 +154,3 @@ describe('automation restore uses the execution computer', () => {
expect(h.state().baseline).not.toBeNull();
});
});
-
-describe('a new teammate preference supersedes the old automation baseline', () => {
- it.each([false, true])('clears the scope only after selection succeeds (fails=%s)', async fails => {
- const h = fixture();
- const originalBaseline = h.state().baseline;
- const stage = vi.fn(async () => {
- if (fails) throw new Error('unavailable');
- h.state().current.providerId = 'new-preference';
- });
- const clear = vi.fn(h.deps.write);
- const apply = compile('bot', {
- stageSessionRouteSelection: stage, updateScheduledPreference: clear, isSessionIdleForRouteApply: () => false,
- });
- const request = apply('task', { ...choice, agentDeviceId: 'share:new' }, choice);
- if (fails) {
- await expect(request).rejects.toThrow('unavailable');
- expect(clear).not.toHaveBeenCalled();
- expect(h.state().baseline).toBe(originalBaseline);
- } else {
- await request;
- expect(clear).toHaveBeenCalledExactlyOnceWith('task', null);
- expect(h.state().baseline).toBeNull();
- // The ordinary send's restore must leave the newly selected route intact.
- await h.scope.restore('task');
- expect(h.state().current.providerId).toBe('new-preference');
- expect(h.applyModel).not.toHaveBeenCalled();
- }
- });
-});
diff --git a/apps/desktop/src/main/maker-ipc/botModelRouteReconciler.ts b/apps/desktop/src/main/maker-ipc/botModelRouteReconciler.ts
index 671aa68771..6aef57f08e 100644
--- a/apps/desktop/src/main/maker-ipc/botModelRouteReconciler.ts
+++ b/apps/desktop/src/main/maker-ipc/botModelRouteReconciler.ts
@@ -53,6 +53,8 @@ export function createBotModelRouteReconciler(deps: {
withSessionLock?<T>(sessionId: string, run: () => Promise<T>): Promise<T>;
read(sessionId: string, purpose: 'apply' | 'preview'): Promise<BotRouteState | null>;
apply(sessionId: string, route: RuntimeRoute, current: RuntimeRoute): Promise<void>;
+ /** An accepted permanent choice supersedes temporary preferences, even without a switch. */
+ onSelectionAccepted?(sessionId: string): Promise<void>;
}) {
let owner: string | undefined;
const configured = new Map<string, string>();
@@ -87,23 +89,28 @@ export function createBotModelRouteReconciler(deps: {
throwIpcError('PRECONDITION_FAILED', '请先选择已开启的伙伴模型');
}
const key = JSON.stringify(state.chain);
- const route = configuredRoute(state, configured.get(sessionId));
+ const previous = configured.get(sessionId);
+ const route = configuredRoute(state, previous);
if (!route) {
configured.set(sessionId, key);
return;
}
const current = state.current;
- if (!sameRoute(route, current) || (state.next && !sameRoute(route, state.next))) {
- try {
- await deps.apply(sessionId, route, state.current);
- } catch (error) {
- // A failed obsolete selection must not discard a newer explicit save.
- // Re-read its route and runtime state; never retry the same failure
- // indefinitely or continue applying after the account owner changes.
- if (deps.ownerEpoch() !== epoch) throw new Error('Bot model route owner changed');
- if ((revisions.get(sessionId) ?? 0) !== revision) continue;
- throw error;
+ const needsApply = !sameRoute(route, current) || !!(state.next && !sameRoute(route, state.next));
+ try {
+ if (needsApply) await deps.apply(sessionId, route, current);
+ if (deps.ownerEpoch() !== epoch) throw new Error('Bot model route owner changed');
+ if ((revisions.get(sessionId) ?? 0) !== revision) continue;
+ // profileChanged marks previous as ''; ordinary matching reconciliation
+ // must leave an in-flight automation scope intact.
+ if (needsApply || (previous !== undefined && previous !== key)) {
+ await deps.onSelectionAccepted?.(sessionId);
}
+ } catch (error) {
+ // A failed obsolete selection must not discard a newer explicit save.
+ if (deps.ownerEpoch() !== epoch) throw new Error('Bot model route owner changed');
+ if ((revisions.get(sessionId) ?? 0) !== revision) continue;
+ throw error;
}
if (deps.ownerEpoch() !== epoch) throw new Error('Bot model route owner changed');
if ((revisions.get(sessionId) ?? 0) !== revision) continue;
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index fa8afdfb7f..15e4af83a0 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -195,7 +195,7 @@ import {
readInputDeliveryClientIds,
} from '@cindy/device-link';
import { and, asc, desc, eq, gte, inArray, isNull, like, lt, or, sql } from 'drizzle-orm';
-import { applyScheduledModelSelection, createScheduledModelScope, resolveScheduledModelSelection, ScheduledModelSelectionBusyError, type ScheduledModelSelection, type ScheduledModelSelectionLease } from './scheduledModelSelection';
+import { applyScheduledModelSelection, createScheduledModelScope, createScheduledModelSelectionResolver, ScheduledModelSelectionBusyError, type ScheduledModelSelection, type ScheduledModelSelectionLease } from './scheduledModelSelection';
import { parseScheduledModelBaseline } from '../../shared/scheduledModelBaseline';
import { recordTurnModelChange, type TurnModelIdentity } from './turnModelChange';
import { app, BrowserWindow, dialog, ipcMain, shell, type IpcMainInvokeEvent } from 'electron';
@@ -10876,19 +10876,16 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
remoteHostId: row.remoteHostId, agentDeviceId: row.agentDeviceId, orcaRole: row.orcaRole } : null;
},
isBusy: () => isSessionInTurn(sessionId) || !!maker.getSession(sessionId)?.isTurnRunning(),
- resolveSelection: async (route, target) => {
- if (target?.agentDeviceId && !target.remoteHostId) {
- const providers = await readUsableAgentDeviceProviders(
- target.agentDeviceId, route.agentKind, route.model, route.providerId,
- );
- return resolveScheduledModelSelection(route, providers);
- }
- const reroute = await assertModelRouteUsable(route.agentKind, route.model, route.providerId);
- return resolveScheduledModelSelectionLive({ ...route,
- providerId: reroute && shouldApplyExclusiveProviderRerouteLive(route.providerId)
- ? reroute : route.providerId,
- });
- },
+ resolveSelection: createScheduledModelSelectionResolver({
+ readRemoteProviders: readUsableAgentDeviceProviders,
+ resolveLocalSelection: async (route) => {
+ const reroute = await assertModelRouteUsable(route.agentKind, route.model, route.providerId);
+ return resolveScheduledModelSelectionLive({ ...route,
+ providerId: reroute && shouldApplyExclusiveProviderRerouteLive(route.providerId)
+ ? reroute : route.providerId,
+ });
+ },
+ }),
switchHarness: async (route) => {
const [savedModes] = await getDbClient().drizzle
.select({ planMode: sessions.planModeEnabled }).from(sessions)
@@ -15885,6 +15882,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
const reconcileBotModelRoute = createBotModelRouteReconciler({
ownerEpoch: captureSessionRuntimeControlOwnerEpoch,
+ onSelectionAccepted: (sessionId) => updateScheduledPreference(sessionId, null),
withSessionLock: withSendToSessionLock,
read: async (sessionId, purpose) => {
const [row] = await getDbClient().drizzle.select({
@@ -15939,9 +15937,6 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
},
apply: async (sessionId, route, current) => {
await stageSessionRouteSelection(sessionId, { ...route, agentDeviceId: route.agentDeviceId ?? null }, current.agentKind);
- // The permanent teammate route has superseded the pre-automation preference.
- // Do not restore that stale source before the next ordinary send (#6745).
- await updateScheduledPreference(sessionId, null);
// Consume the same model/Harness intent as the normal send path. Its
// verified window protection and history handoff also apply here; a Bot
// settings save need not wait for a second user message. Busy runtimes
diff --git a/apps/desktop/src/main/maker-ipc/scheduledModelSelection.ts b/apps/desktop/src/main/maker-ipc/scheduledModelSelection.ts
index dce562d73a..2fb3859df1 100644
--- a/apps/desktop/src/main/maker-ipc/scheduledModelSelection.ts
+++ b/apps/desktop/src/main/maker-ipc/scheduledModelSelection.ts
@@ -1,5 +1,5 @@
import type { AgentKind, Effort } from '@cindy/maker-core';
-import { effectiveSourceIdForModel, findCatalogModel, type ProviderView } from '@cindy/model-providers';
+import { effectiveSourceIdForModel, findCatalogModel, isModelSelectableForNewRoute, type ProviderView } from '@cindy/model-providers';
import { resolveCompatibleSessionRuntimeEffort } from './sessionRuntimeControl';
import { parseScheduledModelBaseline, type ScheduledModelBaseline } from '../../shared/scheduledModelBaseline';
@@ -92,7 +92,8 @@ export function resolveScheduledModelSelection(
effectiveSourceIdForModel(providers, null, selection.model, selection.agentKind);
const provider = providers.find((candidate) => candidate.id === providerId);
const model = findCatalogModel(provider, selection.model, selection.agentKind, { exact: true });
- if (!provider?.connected || provider.suspended === true || !model || model.disabled === true) {
+ if (!provider?.connected || provider.suspended === true || !model ||
+ !isModelSelectableForNewRoute(model, { userProvider: provider.source === 'user' })) {
throw new Error(`Scheduled model "${selection.model}" is unavailable from provider "${providerId ?? 'default'}"`);
}
return {
@@ -103,6 +104,22 @@ export function resolveScheduledModelSelection(
};
}
+/** Resolve against the bound execution computer; inactive replacements use the local path. */
+export function createScheduledModelSelectionResolver(deps: {
+ readRemoteProviders: (deviceId: string, agent: AgentKind, model: string, providerId: string | null) => Promise<ProviderView[]>;
+ resolveLocalSelection: (selection: ScheduledModelSelection) => Promise<ScheduledModelSelection>;
+}) {
+ return async (selection: ScheduledModelSelection, target?: ScheduledModelTarget | null): Promise<ScheduledModelSelection> => {
+ if (target?.agentDeviceId && !target.remoteHostId) {
+ const providers = await deps.readRemoteProviders(
+ target.agentDeviceId, selection.agentKind, selection.model, selection.providerId,
+ );
+ return resolveScheduledModelSelection(selection, providers);
+ }
+ return deps.resolveLocalSelection(selection);
+ };
+}
+
/** Reuse the ordinary history handoff; never stage an automation intent on a busy task. */
export async function applyScheduledModelSelection(
selection: ScheduledModelSelection,
diff --git a/docs/product-rules/model-selector-unified.md b/docs/product-rules/model-selector-unified.md
index a060b14854..7b2829d84b 100644
--- a/docs/product-rules/model-selector-unified.md
+++ b/docs/product-rules/model-selector-unified.md
@@ -207,7 +207,7 @@
绑定已有任务的自动化在保存时只更新自动化配置,下次触发时才通过现有任务切换流程应用完整选择;目标正忙时顺延,不能抢占当前轮次。新增的 `modelAgentKind` 标识显式 Harness 选择;旧记录不补默认值,继续跟随绑定任务的 Harness。选择“跟随”会清除整套显式覆盖,切换新建/绑定模式往返时保留用户已选配置。
-自动化应用模型以及恢复之前的模型偏好时,都按绑定任务当前的 Agent 执行位置校验来源与模型;同账号远程电脑和分享来源使用对应电脑的目录,不能拿本机目录判定不可用,也不能静默换成本机来源。重启后遗留的恢复记录沿用同一规则,无需补字段。伙伴永久模型链成功登记新路由后,清除被新选择取代的旧自动化恢复记录,避免下一条普通消息恢复旧来源;登记失败仍保留原记录。
+自动化应用模型以及恢复之前的模型偏好时,都按活动任务当前的 Agent 执行位置校验来源与模型,并遵守现有新路由准入(含停用、退役、付费与对话能力限制);同账号远程电脑和分享来源使用对应电脑的目录,不能拿本机目录判定不可用,也不能静默换成本机来源。重启后遗留的恢复记录沿用同一规则,无需补字段。绑定任务已归档、删除或缺失时,替代任务按 runner 的本机新建位置解析,不沿用旧执行电脑。伙伴永久模型选择成功处理后(包括选择已与当前临时模型一致、无需切换的情况),清除被新选择取代的旧自动化恢复记录,避免下一条普通消息恢复旧来源;登记失败仍保留原记录。
项目自动化的 `schedules.json` 同样保存可选的 `modelAgentKind`,导出、加载与配置同步均保留该标记;删除标记时清除数据库中的覆盖,已有绑定任务不丢失。旧版 `version: 1` 文件无需补字段。自动触发前按实际来源、Harness 和模型的当前目录拷贝补齐或收敛 effort,并清除已不受支持的 Fast;仍有效的用户选择保持不变。