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(agent): 补齐重启限额恢复的去重与暂停边界

Dash95fe0b027143
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.ts
index 0ff0332147..e525d4598a 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.ts
@@ -14274,6 +14274,38 @@ describe('usage-limit wait (ordinary tasks)', () => {
expect(h.coordinator.restoreUsageLimitRecovery(sid, snapshot, h.coordinator.getGeneration(sid))).not.toBeNull();
});
+ // Standard regression: register restores the quota recovery inside loadQueueSnapshot.
+ // The saved continuation must run once while ordinary restored inputs stay paused in FIFO order.
+ it.each(['active-turn', 'queue-head'] as const)('resumes restored %s quota input without releasing its paused tail', async (kind) => {
+ const h = createHarness(); const sid = `restored-quota-tail-${kind}`;
+ const snapshot = { kind, item: makeItem('quota-input', 'original work'), error: 'weekly limit' };
+ let token!: number;
+ h.setHasAssistantProgressAfter(async () => false);
+ h.setLoadQueueSnapshot(async () => {
+ token = h.coordinator.restoreUsageLimitRecovery(sid, snapshot, h.coordinator.getGeneration(sid))!;
+ return [makeItem('tail-1', 'next work'), makeItem('tail-2', 'last work')];
+ });
+ await h.coordinator.ensureQueueRestored(sid);
+ expect(h.coordinator.getProjection(sid).queuePaused).toBe(true);
+ expect(h.coordinator.armUsageLimitWait(sid, token, 9_000_000)).toBe(true);
+ expect(await h.coordinator.continueAfterUsageLimitReset(sid, token, INFO)).toBe('resumed');
+ await flush();
+ expect(h.sendToAgent).toHaveBeenCalledOnce();
+ expect(h.sendToAgent.mock.calls[0][1]).toMatchObject({ content: 'original work' });
+ // A second quota failure must use the same permission to retry without opening the tail.
+ h.setRunning(false); h.coordinator.onTurnEvent(sid, 'error', 'weekly limit', LIMIT_SIGNALS);
+ const nextToken = h.onUsageLimitedTurnError.mock.calls.at(-1)?.[3] as number;
+ expect(h.coordinator.armUsageLimitWait(sid, nextToken, 10_000_000)).toBe(true);
+ expect(await h.coordinator.continueAfterUsageLimitReset(sid, nextToken, INFO)).toBe('resumed');
+ await flush();
+ expect(h.sendToAgent).toHaveBeenCalledTimes(2);
+ h.setRunning(false); h.coordinator.onTurnEvent(sid, 'done'); await flush();
+ expect(h.sendToAgent).toHaveBeenCalledTimes(2);
+ const projection = h.coordinator.getProjection(sid);
+ expect(projection.queuePaused).toBe(true);
+ expect(projection.pendingQueue.map(item => item.clientId)).toEqual(['tail-1', 'tail-2']);
+ });
+
const LIMIT_SIGNALS = { sdkError: 'rate_limit', usageResetAt: 5_000_000 };
// Regression: scheduled quota failures used to discard recovery before the
// reset-time resolver could run. A real run keeps Retry and the same origin.
@@ -14780,6 +14812,8 @@ describe('usage-limit wait (ordinary tasks)', () => {
const lease = h.coordinator.leaseUsageLimitRecovery(sid, candidate);
h.coordinator.onSessionClosed(sid);
const token = h.coordinator.rearmUsageLimitWait(sid, lease!, null);
+ expect(h.coordinator.hasUsageLimitRecovery(sid, token!)).toBe(true);
+ h.coordinator.onSessionClosed(sid, { preserveAutoResumeIntent: true });
// 只登记候选:还不显示等待,直到求出重置时刻再挂上。
expect(latestProjection(h.projections).usageLimitWait).toBeNull();
expect(h.coordinator.armUsageLimitWait(sid, token!, 9_000_000)).toBe(true);
diff --git a/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts b/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
index adae734915..6c05001b67 100644
--- a/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
+++ b/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
@@ -777,7 +777,6 @@ interface SessionInputState {
resumeAt: number | null;
token: number;
recovery: NonNullable<AgentInputRecovery>;
- accountLimit?: boolean;
} | null;
/**
* 供应商组正在为这次错误换电脑(docs/product-rules/provider-groups.md §6.1):错误仍是当前状态,
@@ -1255,6 +1254,10 @@ export class AgentInputCoordinator {
*/
private readonly restoredQueueSessions = new Set<string>();
private readonly restoredUsageLimitRecoveries = new WeakSet<object>();
+ /** The quota classification belongs to the recovery, and survives runtime/token replacement. */
+ private readonly accountLimitRecoveries = new WeakSet<object>();
+ /** Only this saved continuation can cross a restore pause; the ordinary queue stays paused. */
+ private readonly restoredUsageLimitRetryItems = new WeakSet<AgentInputQueuedMessage>();
private readonly restoredQueueItems = new WeakSet<AgentInputQueuedMessage>();
private readonly restoreAttempted = new Set<string>();
private readonly queueRestorePromises = new Map<string, Promise<void>>();
@@ -1639,13 +1642,18 @@ export class AgentInputCoordinator {
// (composer 发送 / 中断横幅「继续任务」,见 enqueue 的 resumeRestorePausedQueue)
// 自动放行。会话已在忙(恢复窗口期间新输入已开跑)时不强行暂停,恢复项按
// 正常 FIFO 跟在当前工作后面。
+ const quotaRecovery = state.recovery;
+ const quotaHead = quotaRecovery?.kind === 'queue-head' && this.restoredUsageLimitRecoveries.has(quotaRecovery)
+ ? state.pendingQueue.find(item => item.clientId === quotaRecovery.clientId) : undefined;
const wasQuiet =
- state.pendingQueue.length === 0 &&
+ state.pendingQueue.every(item => item === quotaHead) &&
state.activeTurn === null &&
state.steeringQueueClientIds.length === 0 &&
!this.deps.isTurnRunning(sessionId);
for (const item of restored) this.restoredQueueItems.add(item);
- state.pendingQueue = [...restored, ...state.pendingQueue];
+ state.pendingQueue = quotaHead
+ ? [quotaHead, ...restored, ...state.pendingQueue.filter(item => item !== quotaHead)]
+ : [...restored, ...state.pendingQueue];
if (wasQuiet) {
state.queuePaused = true;
state.queuePausedByRestore = true;
@@ -3358,6 +3366,7 @@ export class AgentInputCoordinator {
// Keep the original user input/receipt and user-turn accounting. Only the
// recovery activity metadata travels with its first durable user row.
state.pendingQueue[0].autoResumeInfo = automaticResumeInfo;
+ if (state.queuePausedByRestore) this.restoredUsageLimitRetryItems.add(state.pendingQueue[0]);
}
if (recovery.kind === 'active-turn') {
let item = continueItem;
@@ -3395,6 +3404,7 @@ export class AgentInputCoordinator {
// Manual retry is a user takeover. The old scheduler waiter settles as
// failed; its FireContext must not be inherited by the user's new turn.
if ((!automatic || this.restoredUsageLimitRecoveries.has(recovery)) && isSchedulerOriginItem(item)) item.origin = undefined;
+ if (usageWait && state.queuePausedByRestore) this.restoredUsageLimitRetryItems.add(item);
state.pendingQueue.unshift(item);
this.prependPendingCompactWaitClientId(state, item.clientId);
// 「用户显式重试」信号 —— **只在 active-turn recovery 上发**。这一支重试的是
@@ -4827,7 +4837,7 @@ export class AgentInputCoordinator {
if (this.restoreAttempted.has(sessionId) && !this.restoredQueueSessions.has(sessionId))
return 'queue-restore-failed';
if (state.pendingQueue.length === 0) return 'queue-empty';
- if (state.queuePaused)
+ if (state.queuePaused && !(state.queuePausedByRestore && this.restoredUsageLimitRetryItems.has(state.pendingQueue[0])))
return state.queuePausedByRestore ? 'queue-paused-by-restore' : 'queue-paused';
if (state.queueAbortPending) return 'abort-pending';
if (state.queueInteractionLocks.length > 0) return 'interaction-lock';
@@ -6716,8 +6726,8 @@ export class AgentInputCoordinator {
const token = ++this.usageLimitWaitSeq;
state.usageLimitWait = {
resumeAt: null, token, recovery: state.recovery!,
- accountLimit: isAccountUsageLimitError({ ...signals, message }),
};
+ if (isAccountUsageLimitError({ ...signals, message })) this.accountLimitRecoveries.add(state.recovery!);
try {
this.deps.onUsageLimitedTurnError!(sessionId, { ...(signals ?? {}), message }, item, token);
} catch (err) {
@@ -6884,7 +6894,7 @@ export class AgentInputCoordinator {
/** Includes reset-time resolution: a provider self-close must not cancel the logical wait. */
hasUsageLimitRecovery(sessionId: string, token?: number): boolean {
const state = this.states.get(sessionId);
- return Boolean(state?.usageLimitWait?.accountLimit && isUsageLimitCandidateCurrent(state, token));
+ return Boolean(state?.recovery && this.accountLimitRecoveries.has(state.recovery) && isUsageLimitCandidateCurrent(state, token));
}
snapshotUsageLimitRecovery(sessionId: string, token: number): UsageLimitRecoverySnapshot | null {
@@ -6909,7 +6919,8 @@ export class AgentInputCoordinator {
} else state.recovery = { kind: 'active-turn', item };
state.error = snapshot.error;
const token = ++this.usageLimitWaitSeq;
- state.usageLimitWait = { token, resumeAt: null, recovery: state.recovery, accountLimit: true };
+ state.usageLimitWait = { token, resumeAt: null, recovery: state.recovery };
+ this.accountLimitRecoveries.add(state.recovery);
this.restoredUsageLimitRecoveries.add(state.recovery);
this.emit(sessionId);
return token;
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index ab73308d3f..c5dae47612 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -1680,6 +1680,19 @@ export async function reconcileScheduledUsageLimitWaits(scheduleId: string): Pro
}
}
+/** Reuse the saved wait owner; a fresh-session schedule must not bypass it after restart. */
+export async function findSchedulerUsageLimitWait(scheduleId: string): Promise<string | null> {
+ const scope = activeOwnerScopeKey();
+ for (const [sessionId, pending] of savedUsageLimitWaits) {
+ if (pending.record.item.origin?.kind !== 'scheduler' || pending.record.item.origin.scheduleId !== scheduleId) continue;
+ const valid = await isSavedUsageLimitWaitValid(pending.record);
+ if (usageLimitRecoverySuspended || scope !== activeOwnerScopeKey()) return null;
+ if (valid && savedUsageLimitWaits.get(sessionId) === pending &&
+ agentInputCoordinatorHolder?.leaseUsageLimitRecovery(sessionId, pending.token)) return sessionId;
+ }
+ return null;
+}
+
async function restoreSavedUsageLimitWait(sessionId: string): Promise<void> {
const coordinator = agentInputCoordinatorHolder;
if (!coordinator || usageLimitRecoverySuspended || savedUsageLimitWaits.has(sessionId) ||
diff --git a/apps/desktop/src/main/scheduler-host/__tests__/runnerDefer.test.ts b/apps/desktop/src/main/scheduler-host/__tests__/runnerDefer.test.ts
index 3ca2d4646d..adc126309b 100644
--- a/apps/desktop/src/main/scheduler-host/__tests__/runnerDefer.test.ts
+++ b/apps/desktop/src/main/scheduler-host/__tests__/runnerDefer.test.ts
@@ -119,6 +119,7 @@ function createFireContext(): FireContext & { abortController: AbortController }
interface RunnerHarnessOptions {
createSessionImpl?: () => Promise<Session>;
sessionAlive?: boolean;
+ findUsageLimitWait?: (scheduleId: string) => Promise<string | null>;
}
function createRunnerHarness(session: Session, options: RunnerHarnessOptions = {}) {
@@ -137,7 +138,8 @@ function createRunnerHarness(session: Session, options: RunnerHarnessOptions = {
getSessionMeta: vi.fn(async () => ({ sdkSessionId: 'sdk-1', workDir: 'F:\\X', model: 'gpt-5.4' })),
isSessionAlive: vi.fn(() => options.sessionAlive ?? true),
} as unknown as Maker;
- const runner = new MakerScheduleRunner({ maker, getDb: () => ({}) as never, notifier, logger });
+ const runner = new MakerScheduleRunner({ maker, getDb: () => ({}) as never, notifier, logger,
+ findUsageLimitWait: options.findUsageLimitWait });
return { runner, logger, notifier, maker };
}
@@ -149,6 +151,21 @@ describe('MakerScheduleRunner 顺延 / 礼让', () => {
mocks.resolveWorkingDir.mockResolvedValue({ ok: true, path: 'F:\\X' });
});
+ // Standard regression: after restart a schedule's saved wait belongs to its old session,
+ // including schedules that normally create a fresh session on every fire.
+ it.each([undefined, 'heartbeat-session'])('defers a saved quota wait before creating or sending to target=%s', async (targetSessionId) => {
+ const h = createSessionHarness(async () => ({ accepted: true }));
+ const findUsageLimitWait = vi.fn(async () => 'old-quota-session');
+ const { runner, maker, notifier } = createRunnerHarness(h.session, { findUsageLimitWait });
+ const result = await runner.fire(heartbeatSchedule({ targetSessionId }), createFireContext());
+ expect(result).toMatchObject({ deferred: true, sessionId: 'old-quota-session' });
+ expect(findUsageLimitWait).toHaveBeenCalledWith('schedule-hb');
+ expect(maker.createSession).not.toHaveBeenCalled();
+ expect(h.send).not.toHaveBeenCalled();
+ expect(mocks.resolveWorkingDir).not.toHaveBeenCalled();
+ expect(notifier.notify).not.toHaveBeenCalled();
+ });
+
it('does not create a session or send a turn for a pre-aborted run', async () => {
const h = createSessionHarness(async () => ({ accepted: true }));
const { runner, maker } = createRunnerHarness(h.session);
diff --git a/apps/desktop/src/main/scheduler-host/__tests__/schedulerQueueWiring.test.ts b/apps/desktop/src/main/scheduler-host/__tests__/schedulerQueueWiring.test.ts
index 6550d7d6b8..42687eb087 100644
--- a/apps/desktop/src/main/scheduler-host/__tests__/schedulerQueueWiring.test.ts
+++ b/apps/desktop/src/main/scheduler-host/__tests__/schedulerQueueWiring.test.ts
@@ -4,6 +4,7 @@ import type { StartSchedulerDeps } from '../index';
const mocks = vi.hoisted(() => ({
restore: vi.fn<(sessionId: string) => Promise<boolean>>(),
+ quotaWait: vi.fn<(scheduleId: string) => Promise<string | null>>(),
runnerDeps: null as MakerScheduleRunnerDeps | null,
}));
@@ -25,6 +26,7 @@ vi.mock('../../agent-island/service.js', () => ({ getAgentIslandService: () => n
vi.mock('../../notificationService.js', () => ({ getDesktopNotificationsEnabled: () => false }));
vi.mock('../../maker-ipc/register.js', () => ({
ensureSchedulerQueueRestored: mocks.restore,
+ findSchedulerUsageLimitWait: mocks.quotaWait,
applyPiImModelSelectionUnderLock: vi.fn(), acquirePendingAgentSwitchForDirectSend: vi.fn(),
preserveScheduledModelPreferencesUnderLock: vi.fn(), recordDispatchedModel: vi.fn(),
broadcastSessionCreated: vi.fn(), cancelSchedulerAutoResume: vi.fn(),
@@ -57,6 +59,7 @@ import { resetScheduler, startScheduler } from '../index';
afterEach(async () => {
await resetScheduler();
mocks.restore.mockReset();
+ mocks.quotaWait.mockReset();
mocks.runnerDeps = null;
});
@@ -73,5 +76,9 @@ describe('scheduler queue wiring', () => {
expect(restore).toBe(mocks.restore);
await expect(restore!('restored-session')).resolves.toBe(restored);
expect(mocks.restore).toHaveBeenCalledExactlyOnceWith('restored-session');
+ // Production startup must retain schedule-wide quota deduplication, including fresh-session fires.
+ mocks.quotaWait.mockResolvedValue('old-quota-session');
+ await expect(mocks.runnerDeps?.findUsageLimitWait?.('schedule')).resolves.toBe('old-quota-session');
+ expect(mocks.quotaWait).toHaveBeenCalledExactlyOnceWith('schedule');
});
});
diff --git a/apps/desktop/src/main/scheduler-host/index.ts b/apps/desktop/src/main/scheduler-host/index.ts
index 9d0296ebf5..1d0cfec1b5 100644
--- a/apps/desktop/src/main/scheduler-host/index.ts
+++ b/apps/desktop/src/main/scheduler-host/index.ts
@@ -45,6 +45,7 @@ import {
cancelSchedulerAutoResume,
enqueueSchedulerPrompt,
ensureSchedulerQueueRestored,
+ findSchedulerUsageLimitWait,
hasQueuedSchedulerPrompt,
isSchedulerAutoResumePending,
isSchedulerPromptTracked,
@@ -128,6 +129,7 @@ async function startSchedulerInternal(deps: StartSchedulerDeps): Promise<Schedul
return listMessagesForAgentHandoff(sessionId, null, undefined, 'authorization');
},
onUndispatchedUserTurn: deps.onUndispatchedUserTurn,
+ findUsageLimitWait: findSchedulerUsageLimitWait,
acquirePendingAgentSwitch: acquirePendingAgentSwitchForDirectSend,
preserveModelPreferences: preserveScheduledModelPreferencesUnderLock,
onModelDispatched: recordDispatchedModel,
diff --git a/apps/desktop/src/main/scheduler-host/runner.ts b/apps/desktop/src/main/scheduler-host/runner.ts
index af12890a27..0e2c20d7d7 100644
--- a/apps/desktop/src/main/scheduler-host/runner.ts
+++ b/apps/desktop/src/main/scheduler-host/runner.ts
@@ -275,6 +275,8 @@ export interface MakerScheduleRunnerDeps {
readAutoReviewHistory?: (sessionId: string) => Promise<AutoReviewHistoryMessage[]>;
beforeDispatchUserTurn?: (sessionId: string) => void | Promise<void>;
onUndispatchedUserTurn?: (sessionId: string) => void;
+ /** Saved quota waits deduplicate by schedule even when each fire creates a new task. */
+ findUsageLimitWait?: (scheduleId: string) => Promise<string | null>;
/**
* 锁住 heartbeat session、落实 deferred switch 并 bootstrap 新 live session。
* runner 在 Session.send 返回后 release。
@@ -577,6 +579,7 @@ export class MakerScheduleRunner implements ScheduleRunner {
| 'session-running'
| 'already-queued'
| 'queue-restore-pending'
+ | 'usage-limit-wait'
| 'routine-permission-unavailable'
| 'routine-dispatch-invalidated'
| 'queue-wait-timeout',
@@ -787,6 +790,14 @@ export class MakerScheduleRunner implements ScheduleRunner {
ctx: FireContext,
holder: EphemeralSessionHolder,
): Promise<FireResult> {
+ const waitingSessionId = await this.deps.findUsageLimitWait?.(schedule.id);
+ throwIfFireAborted(ctx.signal, 'quota wait check');
+ if (waitingSessionId) {
+ if (this.canDefer(schedule, ctx)) return this.deferFire(schedule, waitingSessionId, 'usage-limit-wait');
+ const message = 'SCHEDULE_USAGE_LIMIT_WAIT: this schedule already has a task waiting for quota recovery';
+ await this.notifyFailureSilent(schedule, ctx, message);
+ throw new Error(message);
+ }
// 1. effort 白名单
if (schedule.effort && !ALLOWED_EFFORT.has(schedule.effort)) {
const errMsg = `invalid effort: ${schedule.effort}`;
@@ -3796,6 +3807,7 @@ function extractErr(data: unknown): string {
*/
type FireAbortStage =
| 'runner entry'
+ | 'quota wait check'
| 'queue snapshot restore'
| 'workspace allocation'
| 'session creation'
diff --git a/apps/desktop/src/main/usage/__tests__/claudeSubscriptionUsageRefresh.test.ts b/apps/desktop/src/main/usage/__tests__/claudeSubscriptionUsageRefresh.test.ts
index 61c84bda65..9a858d2bc9 100644
--- a/apps/desktop/src/main/usage/__tests__/claudeSubscriptionUsageRefresh.test.ts
+++ b/apps/desktop/src/main/usage/__tests__/claudeSubscriptionUsageRefresh.test.ts
@@ -65,6 +65,20 @@ describe('createClaudeSubscriptionUsageReader', () => {
expect(state.cached).toMatchObject({ source: 'oauth-endpoint', accountFingerprint: 'acct-a' });
});
+ // Standard regression: fresh recovery reads must await the new account even if an old refresh is in flight.
+ it.each([false, true])('waits for the current account after discarding its old cache; inFlight=%s', async (inFlight) => {
+ const { deps, reader, state } = setup({ cached: { ...SNAPSHOT, accountFingerprint: 'acct-a' } });
+ let release!: (value: ClaudeSubscriptionUsageSnapshot) => void;
+ if (inFlight) {
+ deps.fetchSnapshot.mockImplementationOnce(() => new Promise(resolve => { release = resolve; }));
+ reader.triggerRefresh();
+ }
+ state.account = 'acct-b';
+ const result = reader.read({ fresh: true });
+ if (inFlight) { await flush(); release(SNAPSHOT); }
+ expect(await result).toMatchObject({ accountFingerprint: 'acct-b', sevenDay: SNAPSHOT.sevenDay });
+ });
+
it('节流窗口内不重复拉起 CLI,过了窗口再拉', async () => {
const { deps, reader, state } = setup();
await reader.read();
diff --git a/apps/desktop/src/main/usage/claudeSubscriptionUsageRefresh.ts b/apps/desktop/src/main/usage/claudeSubscriptionUsageRefresh.ts
index 109da29a3d..74331ec02e 100644
--- a/apps/desktop/src/main/usage/claudeSubscriptionUsageRefresh.ts
+++ b/apps/desktop/src/main/usage/claudeSubscriptionUsageRefresh.ts
@@ -106,9 +106,9 @@ export function createClaudeSubscriptionUsageReader(
if (inFlight) {
// 飞行中的请求属于另一个账号:旧结果会被丢弃,收尾后按当时的账号补一次。
if (inFlightAccount !== account) {
- return inFlight.finally(() => {
+ return inFlight.then(() => {
const current = readAccountSafe();
- if (current !== null) void refreshFor(current);
+ if (current !== null) return refreshFor(current);
});
}
return inFlight;
@@ -155,17 +155,18 @@ export function createClaudeSubscriptionUsageReader(
// 读缓存期间换号:按旧账号做的归属判断已失效,既不返回(可能是旧账号的余量)也不清理
// (新账号的快照可能刚写入)。新账号的余量随登录态同步 / 刷新广播。
if (readAccountSafe() !== account) return null;
- if (belongsToOtherAccount(cached, account)) {
+ const otherAccount = belongsToOtherAccount(cached, account);
+ if (otherAccount) {
await clearSnapshotSafe();
- void refreshFor(account);
- return null;
}
+ if (readAccountSafe() !== account) return null;
if (options?.fresh) {
await refreshFor(account);
- return readAccountSafe() === account ? deps.readCachedSnapshot() : null;
+ const refreshed = await deps.readCachedSnapshot();
+ return readAccountSafe() === account && !belongsToOtherAccount(refreshed, account) ? refreshed : null;
}
void refreshFor(account);
- return cached;
+ return otherAccount ? null : cached;
},
triggerRefresh(): void {
diff --git a/docs/product-rules/usage-limit-auto-continue.md b/docs/product-rules/usage-limit-auto-continue.md
index 208d2e2f0c..c66e246a7e 100644
--- a/docs/product-rules/usage-limit-auto-continue.md
+++ b/docs/product-rules/usage-limit-auto-continue.md
@@ -51,7 +51,9 @@
正常退出先冻结等待再停 scheduler/Maker,等待写入完成。派发前原子消费保存项,多个实例只能一个续跑;
消费后发生崩溃不重放结果未知的发送,保留既有中断后的手动恢复流程。
重启后旧 schedule run 按既有规则收口,恢复的是该任务的续跑,不复活旧 FireContext;等待时仍阻止
- 同 schedule 再排一份输入,并核对 schedule 未暂停/删除。目标模式沿用已有的持久状态。
+ 同 schedule 再排一份输入(包括每次新建任务的 schedule),并核对 schedule 未暂停/删除。
+ 自动续跑只放行已确认的限额恢复输入;重启恢复的其它排队消息保持原顺序与暂停,用户明确暂停仍有效。
+ 目标模式沿用已有的持久状态。
- 已收到上游终态错误后,远程运行消失等收尾错误不得覆盖原始原因和重置时刻;下一次发送仍独立报告
新错误。额度等待期间 Agent 自行退出只清运行时,保留任务的恢复意图;用户明确关闭任务仍撤销等待。
- 普通任务里用户动手换模型或来源即视为接手,开始切换时就撤销等待(新选择可能有额度;切换失败时错误