Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(goal): show quota-held tasks as waiting, rename lost to stalled (#21584)

Arvin Xu512fa15745c5
diff --git a/apps/server/src/services/goal/GoalService/__tests__/device.test.ts b/apps/server/src/services/goal/GoalService/__tests__/device.test.ts
index 8bafdc8b9e7..f690c82688f 100644
--- a/apps/server/src/services/goal/GoalService/__tests__/device.test.ts
+++ b/apps/server/src/services/goal/GoalService/__tests__/device.test.ts
@@ -18,7 +18,11 @@ import type { LobeChatDatabase } from '@/database/type';
import { deviceGateway } from '../../../deviceGateway';
import { TaskRunnerService } from '../../../taskRunner';
import { MAX_QUOTA_RETRIES } from '../../machineRecovery';
-import { DEVICE_OFFLINE_GATE_REASON, MAX_DEVICE_OFFLINE_RETRIES } from '../../recoveryPolicy';
+import {
+ DEVICE_OFFLINE_GATE_REASON,
+ MAX_DEVICE_OFFLINE_RETRIES,
+ QUOTA_RESET_MARGIN_MS,
+} from '../../recoveryPolicy';
import * as scheduler from '../../scheduler';
import { LocalGoalScheduler } from '../../scheduler/impls';
import { registerGoalServiceTestCleanup } from '../../testUtils';
@@ -468,6 +472,21 @@ describe('GoalService', () => {
expect(after.goal.config?.supervisorState?.incidents ?? []).toHaveLength(0);
});
+ it('tells the page when the held Task retries, so it does not read as lost', async () => {
+ // The held Task's run has ended and sends no heartbeat. Without the retry
+ // time the page judged it by heartbeat alone and called it lost.
+ const resetsAt = Date.now() + 2 * 60 * 60 * 1000;
+ const { created, graph, service } = await setup('Session limit on the page', resetsAt);
+ const nodeId = graph.nodes.find((node) => node.kind === 'task')!.id;
+
+ const snapshot = await service.graph(graph.goal.id);
+
+ expect(created.taskId).toBeDefined();
+ expect(snapshot.quotaRetryAt?.[nodeId]?.getTime()).toBe(
+ Math.floor(resetsAt / 1000) * 1000 + QUOTA_RESET_MARGIN_MS,
+ );
+ });
+
// The refusal's text names the limit, so its runs are uncharged and the
// attempt budget cannot end a window that keeps refusing. The uncharged
// quota schedule does: once spent, a person is asked instead of another wait.
diff --git a/apps/server/src/services/goal/GoalService/__tests__/surface.test.ts b/apps/server/src/services/goal/GoalService/__tests__/surface.test.ts
index 0d03bcc9441..daa9c117972 100644
--- a/apps/server/src/services/goal/GoalService/__tests__/surface.test.ts
+++ b/apps/server/src/services/goal/GoalService/__tests__/surface.test.ts
@@ -48,6 +48,7 @@ const METHODS = [
'collectAcceptances',
'collectAssignees',
'collectDeliveredAt',
+ 'collectQuotaWaits',
'collectRolloutGate',
'collectRunHeartbeats',
'consumeCompletedTask',
diff --git a/apps/server/src/services/goal/GoalService/index.ts b/apps/server/src/services/goal/GoalService/index.ts
index 379134c8636..8231dc7f6eb 100644
--- a/apps/server/src/services/goal/GoalService/index.ts
+++ b/apps/server/src/services/goal/GoalService/index.ts
@@ -78,6 +78,7 @@ import {
collectAcceptances,
collectAssignees,
collectDeliveredAt,
+ collectQuotaWaits,
collectRunHeartbeats,
graph,
listEvents,
@@ -197,6 +198,7 @@ export class GoalService {
collectAcceptances: (...args) => self.collectAcceptances(...args),
collectAssignees: (...args) => self.collectAssignees(...args),
collectDeliveredAt: (...args) => self.collectDeliveredAt(...args),
+ collectQuotaWaits: (...args) => self.collectQuotaWaits(...args),
collectRolloutGate: (...args) => self.collectRolloutGate(...args),
collectRunHeartbeats: (...args) => self.collectRunHeartbeats(...args),
consumeCompletedTask: (...args) => self.consumeCompletedTask(...args),
@@ -353,6 +355,9 @@ export class GoalService {
private collectDeliveredAt = (...args: MethodArgs<typeof collectDeliveredAt>) =>
collectDeliveredAt(this.context, ...args);
+ private collectQuotaWaits = (...args: MethodArgs<typeof collectQuotaWaits>) =>
+ collectQuotaWaits(this.context, ...args);
+
private collectRunHeartbeats = (...args: MethodArgs<typeof collectRunHeartbeats>) =>
collectRunHeartbeats(this.context, ...args);
diff --git a/apps/server/src/services/goal/GoalService/reads.ts b/apps/server/src/services/goal/GoalService/reads.ts
index d533cd7b9b2..92b0bd8a77c 100644
--- a/apps/server/src/services/goal/GoalService/reads.ts
+++ b/apps/server/src/services/goal/GoalService/reads.ts
@@ -8,22 +8,26 @@ import type {
GoalStatus,
} from '@lobechat/types';
import { TRPCError } from '@trpc/server';
+import pMap from 'p-map';
import { AgentOperationModel } from '@/database/models/agentOperation';
+import { classifyRunFailure, QUOTA_RESET_MARGIN_MS } from '../recoveryPolicy';
import { GoalReportStore } from '../reportStore';
import type { GoalServiceContext } from './types';
export const graph = async (ctx: GoalServiceContext, goalId: string) => {
const graph = await ctx.requireGraph(goalId);
- const [runHeartbeats, deliveredAt, acceptances, assignees, spend, report] = await Promise.all([
- ctx.collectRunHeartbeats(graph),
- ctx.collectDeliveredAt(graph),
- ctx.collectAcceptances(graph),
- ctx.collectAssignees(graph),
- ctx.resolveSpend(graph),
- new GoalReportStore(ctx.db, ctx.userId, ctx.workspaceId).state(graph),
- ]);
+ const [runHeartbeats, deliveredAt, quotaRetryAt, acceptances, assignees, spend, report] =
+ await Promise.all([
+ ctx.collectRunHeartbeats(graph),
+ ctx.collectDeliveredAt(graph),
+ ctx.collectQuotaWaits(graph),
+ ctx.collectAcceptances(graph),
+ ctx.collectAssignees(graph),
+ ctx.resolveSpend(graph),
+ new GoalReportStore(ctx.db, ctx.userId, ctx.workspaceId).state(graph),
+ ]);
// Numeric clauses read through the Goal's Widget subscriptions when bound, so
// the page shows the same verdict the coordinator acts on.
const metricCriteria = await ctx.evaluateMetricCriteria(graph);
@@ -33,6 +37,7 @@ export const graph = async (ctx: GoalServiceContext, goalId: string) => {
assignees,
deliveredAt,
metricCriteria,
+ quotaRetryAt,
report,
runHeartbeats,
spend,
@@ -180,6 +185,52 @@ export const collectDeliveredAt = async (
return Object.keys(delivered).length > 0 ? delivered : undefined;
};
+/**
+ * When the coordinator retries each active task node a usage window refused.
+ *
+ * `waitForQuotaReset` holds such a Task `paused` and books its own wake for the
+ * reset, so the run behind it has ended and sends no heartbeat. A client judging
+ * liveness from heartbeats alone called that wait lost — a red failure badge on
+ * a Task the coordinator will resume on its own. This reads the same failure
+ * classification the coordinator does, so the page names the wait and its time.
+ */
+export const collectQuotaWaits = async (
+ ctx: GoalServiceContext,
+ graph: GoalGraphSnapshot,
+): Promise<Record<string, Date> | undefined> => {
+ const activeTasks = graph.nodes.filter(
+ (node): node is GoalGraphNode & { taskId: string } =>
+ node.kind === 'task' && node.status === 'active' && !!node.taskId,
+ );
+ if (activeTasks.length === 0) return undefined;
+
+ const paused = (await ctx.taskModel.findByIds(activeTasks.map((node) => node.taskId))).filter(
+ (task) => task.status === 'paused',
+ );
+ if (paused.length === 0) return undefined;
+
+ const nodeByTaskId = new Map(activeTasks.map((node) => [node.taskId, node.id]));
+ const operationModel = new AgentOperationModel(ctx.db, ctx.userId, ctx.workspaceId);
+ const waits: Record<string, Date> = {};
+ // Paused active Tasks are rare, so the per-task read stays off the common poll;
+ // the cap keeps a goal with many held Tasks from bursting the pool on every poll.
+ await pMap(
+ paused,
+ async (task) => {
+ const [latest] = await ctx.taskTopicModel.findWithHandoff(task.id, 1);
+ if (!latest?.operationId) return;
+ const operation = await operationModel.findById(latest.operationId);
+ const failure = classifyRunFailure(operation?.error, task.error ?? '');
+ const nodeId = nodeByTaskId.get(task.id);
+ if (failure.kind !== 'quota_reset' || !nodeId) return;
+ waits[nodeId] = new Date(failure.resetsAt! + QUOTA_RESET_MARGIN_MS);
+ },
+ { concurrency: 5 },
+ );
+
+ return Object.keys(waits).length > 0 ? waits : undefined;
+};
+
/**
* Live heartbeat per active task node: the `agent_operations.updatedAt` of
* the run behind it. The runtime refreshes that lease every ~90s while
diff --git a/apps/server/src/services/goal/GoalService/types.ts b/apps/server/src/services/goal/GoalService/types.ts
index d4fc81f8619..3aac99d9c35 100644
--- a/apps/server/src/services/goal/GoalService/types.ts
+++ b/apps/server/src/services/goal/GoalService/types.ts
@@ -77,6 +77,7 @@ import type {
collectAcceptances,
collectAssignees,
collectDeliveredAt,
+ collectQuotaWaits,
collectRunHeartbeats,
graph,
listEvents,
@@ -193,6 +194,7 @@ export interface GoalServiceContext {
collectAcceptances: Bound<typeof collectAcceptances>;
collectAssignees: Bound<typeof collectAssignees>;
collectDeliveredAt: Bound<typeof collectDeliveredAt>;
+ collectQuotaWaits: Bound<typeof collectQuotaWaits>;
collectRolloutGate: Bound<typeof collectRolloutGate>;
collectRunHeartbeats: Bound<typeof collectRunHeartbeats>;
consumeCompletedTask: Bound<typeof consumeCompletedTask>;
diff --git a/locales/ar/chat.json b/locales/ar/chat.json
index 2d676f5ff87..c8e0582787f 100644
--- a/locales/ar/chat.json
+++ b/locales/ar/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "طلب تغييرات",
"goalProcess.signOff.requestChangesEffect": "أعده إلى الوكيل. قل ما يجب تغييره في الملاحظات.",
"goalProcess.signOff.sentBack": "تم إرساله لإجراء تغييرات",
- "goalProcess.stale.description": "لا يوجد نبض لمدة {{duration}}. التقدم التالي يعتبر هذه المحاولة مفقودة ويبدأ محاولة جديدة — لا يتم احتسابها كفشل.",
"goalProcess.start": "ابدأ",
"goalProcess.summary.done": "مكتمل · {{count}} محاولات",
"goalProcess.summary.gateOpen": "في انتظار قرارك",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "التنفيذ",
"goalProcess.tabs.result": "التسليم",
"goalProcess.tag.done": "مكتمل",
- "goalProcess.tag.lost": "مفقود",
"goalProcess.tag.needsDecision": "يحتاج إلى قرارك",
"goalProcess.tag.retired": "تم إنهاؤه",
"goalProcess.tag.verifying": "جاري التحقق",
diff --git a/locales/bg-BG/chat.json b/locales/bg-BG/chat.json
index f949dd662b3..eed85e3e0a7 100644
--- a/locales/bg-BG/chat.json
+++ b/locales/bg-BG/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "Поискай промени",
"goalProcess.signOff.requestChangesEffect": "Изпратете го обратно към агента. Кажете какво да се промени в бележките.",
"goalProcess.signOff.sentBack": "Изпратено обратно за промени",
- "goalProcess.stale.description": "Няма активност за {{duration}}. Следващото напредване ще маркира този опит като загубен и ще започне нов — това няма да се счита за провал.",
"goalProcess.start": "Стартирай",
"goalProcess.summary.done": "Завършено · {{count}} опита",
"goalProcess.summary.gateOpen": "Чака вашето решение",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "Изпълнение",
"goalProcess.tabs.result": "Доставка",
"goalProcess.tag.done": "Завършено",
- "goalProcess.tag.lost": "Загубено",
"goalProcess.tag.needsDecision": "Нужно е вашето решение",
"goalProcess.tag.retired": "Прекратено",
"goalProcess.tag.verifying": "Проверка",
diff --git a/locales/de-DE/chat.json b/locales/de-DE/chat.json
index a93e82b46b2..fe9e6cd5475 100644
--- a/locales/de-DE/chat.json
+++ b/locales/de-DE/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "Änderungen anfordern",
"goalProcess.signOff.requestChangesEffect": "Senden Sie es zurück an den Agenten. Geben Sie in den Notizen an, was geändert werden soll.",
"goalProcess.signOff.sentBack": "Zurückgesendet für Änderungen",
- "goalProcess.stale.description": "Kein Signal für {{duration}}. Der nächste Fortschritt markiert diesen Versuch als verloren und startet einen neuen — dies zählt nicht als Fehlschlag.",
"goalProcess.start": "Starten",
"goalProcess.summary.done": "Erledigt · {{count}} Versuche",
"goalProcess.summary.gateOpen": "Warten auf Ihre Entscheidung",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "Ausführung",
"goalProcess.tabs.result": "Lieferung",
"goalProcess.tag.done": "Erledigt",
- "goalProcess.tag.lost": "Verloren",
"goalProcess.tag.needsDecision": "Benötigt Ihre Entscheidung",
"goalProcess.tag.retired": "Zurückgezogen",
"goalProcess.tag.verifying": "Wird überprüft",
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 154a667e3d5..40ae2e3d1d9 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -1072,6 +1072,9 @@
"goalProcess.planning.title": "Planning the exploration",
"goalProcess.portal.openPage": "Open goal page",
"goalProcess.portal.title": "Goal",
+ "goalProcess.quota.resumeAt": "Resumes {{time}}",
+ "goalProcess.quota.resumeSoon": "Resuming soon",
+ "goalProcess.quota.tooltip": "The usage limit was reached. The goal resumes this task on its own once the quota resets — it does not count as a failure.",
"goalProcess.requirementPlaceholder": "Describe what counts as done…",
"goalProcess.requirementSaveFailed": "Failed to save the requirement — it will retry on your next edit",
"goalProcess.result.changes.comment": "Your feedback",
@@ -1194,7 +1197,7 @@
"goalProcess.signOff.requestChanges": "Request changes",
"goalProcess.signOff.requestChangesEffect": "Send it back to the Agent. Say what to change in the notes.",
"goalProcess.signOff.sentBack": "Sent back for changes",
- "goalProcess.stale.description": "No heartbeat for {{duration}}. The next advance marks this attempt lost and starts a fresh one — it does not count as a failure.",
+ "goalProcess.stalled.description": "Last heartbeat {{duration}}. The next advance restarts this attempt — it does not count as a failure.",
"goalProcess.start": "Start",
"goalProcess.summary.done": "Done · {{count}} attempts",
"goalProcess.summary.gateOpen": "Waiting for your decision",
@@ -1206,10 +1209,11 @@
"goalProcess.tabs.process": "Execution",
"goalProcess.tabs.result": "Delivery",
"goalProcess.tag.done": "Done",
- "goalProcess.tag.lost": "Lost",
"goalProcess.tag.needsDecision": "Needs your decision",
"goalProcess.tag.retired": "Retired",
+ "goalProcess.tag.stalled": "Stalled",
"goalProcess.tag.verifying": "Verifying",
+ "goalProcess.tag.waitingQuota": "Waiting for quota",
"goalTask.checks": "{{passed}}/{{total}} checks passed",
"goalTask.plan.drafting": "Breaking the goal into tasks…",
"goalTask.round": "Round {{current}}",
diff --git a/locales/es-ES/chat.json b/locales/es-ES/chat.json
index 6e2bd86bfa2..981fdcda882 100644
--- a/locales/es-ES/chat.json
+++ b/locales/es-ES/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "Solicitar cambios",
"goalProcess.signOff.requestChangesEffect": "Envíalo de vuelta al agente. Indica qué cambiar en las notas.",
"goalProcess.signOff.sentBack": "Enviado de vuelta para cambios",
- "goalProcess.stale.description": "Sin actividad durante {{duration}}. El próximo avance marcará este intento como perdido y comenzará uno nuevo — no cuenta como un fallo.",
"goalProcess.start": "Iniciar",
"goalProcess.summary.done": "Completado · {{count}} intentos",
"goalProcess.summary.gateOpen": "Esperando tu decisión",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "Ejecución",
"goalProcess.tabs.result": "Entrega",
"goalProcess.tag.done": "Completado",
- "goalProcess.tag.lost": "Perdido",
"goalProcess.tag.needsDecision": "Necesita tu decisión",
"goalProcess.tag.retired": "Retirado",
"goalProcess.tag.verifying": "Verificando",
diff --git a/locales/fa-IR/chat.json b/locales/fa-IR/chat.json
index b74cb4fe4f1..2030a4e6b4b 100644
--- a/locales/fa-IR/chat.json
+++ b/locales/fa-IR/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "درخواست تغییرات",
"goalProcess.signOff.requestChangesEffect": "آن را به اجنت بازگردانید. بگویید چه چیزی باید در یادداشت‌ها تغییر کند.",
"goalProcess.signOff.sentBack": "برای تغییرات بازگردانده شد",
- "goalProcess.stale.description": "هیچ ضربان قلبی برای {{duration}}. پیشرفت بعدی این تلاش را از دست رفته علامت‌گذاری می‌کند و یک تلاش جدید را شروع می‌کند — این به عنوان شکست محسوب نمی‌شود.",
"goalProcess.start": "شروع",
"goalProcess.summary.done": "انجام شد · {{count}} تلاش",
"goalProcess.summary.gateOpen": "منتظر تصمیم شما",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "اجرا",
"goalProcess.tabs.result": "تحویل",
"goalProcess.tag.done": "انجام شد",
- "goalProcess.tag.lost": "از دست رفته",
"goalProcess.tag.needsDecision": "نیاز به تصمیم شما دارد",
"goalProcess.tag.retired": "بازنشسته شد",
"goalProcess.tag.verifying": "در حال تأیید",
diff --git a/locales/fr-FR/chat.json b/locales/fr-FR/chat.json
index 300fe085e9a..e4462f172ce 100644
--- a/locales/fr-FR/chat.json
+++ b/locales/fr-FR/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "Demander des modifications",
"goalProcess.signOff.requestChangesEffect": "Renvoyez-le à l'agent. Indiquez ce qu'il faut changer dans les notes.",
"goalProcess.signOff.sentBack": "Renvoyé pour modifications",
- "goalProcess.stale.description": "Aucun signal depuis {{duration}}. Le prochain avancement marquera cette tentative comme perdue et en démarrera une nouvelle — cela ne compte pas comme un échec.",
"goalProcess.start": "Démarrer",
"goalProcess.summary.done": "Terminé · {{count}} tentatives",
"goalProcess.summary.gateOpen": "En attente de votre décision",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "Exécution",
"goalProcess.tabs.result": "Livraison",
"goalProcess.tag.done": "Terminé",
- "goalProcess.tag.lost": "Perdu",
"goalProcess.tag.needsDecision": "Nécessite votre décision",
"goalProcess.tag.retired": "Retiré",
"goalProcess.tag.verifying": "Vérification en cours",
diff --git a/locales/it-IT/chat.json b/locales/it-IT/chat.json
index 3b674fe9666..9d9eb109c25 100644
--- a/locales/it-IT/chat.json
+++ b/locales/it-IT/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "Richiedi modifiche",
"goalProcess.signOff.requestChangesEffect": "Rimandalo all'agente. Indica cosa cambiare nelle note.",
"goalProcess.signOff.sentBack": "Rimandato per modifiche",
- "goalProcess.stale.description": "Nessun segnale per {{duration}}. Il prossimo avanzamento segnerà questo tentativo come perso e ne avvierà uno nuovo — non sarà considerato un fallimento.",
"goalProcess.start": "Avvia",
"goalProcess.summary.done": "Completato · {{count}} tentativi",
"goalProcess.summary.gateOpen": "In attesa della tua decisione",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "Esecuzione",
"goalProcess.tabs.result": "Consegna",
"goalProcess.tag.done": "Completato",
- "goalProcess.tag.lost": "Perso",
"goalProcess.tag.needsDecision": "Necessita della tua decisione",
"goalProcess.tag.retired": "Ritirato",
"goalProcess.tag.verifying": "Verifica in corso",
diff --git a/locales/ja-JP/chat.json b/locales/ja-JP/chat.json
index f084f995ec9..d291bb0b5fd 100644
--- a/locales/ja-JP/chat.json
+++ b/locales/ja-JP/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "変更を要求",
"goalProcess.signOff.requestChangesEffect": "エージェントに送り返します。変更すべき内容をメモに記述してください。",
"goalProcess.signOff.sentBack": "変更のために送り返されました",
- "goalProcess.stale.description": "{{duration}} の間、応答がありません。次の進行でこの試行は失敗として記録され、新しい試行が開始されます — 失敗としてはカウントされません。",
"goalProcess.start": "開始",
"goalProcess.summary.done": "完了 · {{count}} 件の試行",
"goalProcess.summary.gateOpen": "あなたの決定を待っています",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "実行",
"goalProcess.tabs.result": "納品",
"goalProcess.tag.done": "完了",
- "goalProcess.tag.lost": "失敗",
"goalProcess.tag.needsDecision": "あなたの決定が必要です",
"goalProcess.tag.retired": "退役済み",
"goalProcess.tag.verifying": "検証中",
diff --git a/locales/ko-KR/chat.json b/locales/ko-KR/chat.json
index fe2d0c18a20..5edaf227fcf 100644
--- a/locales/ko-KR/chat.json
+++ b/locales/ko-KR/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "변경 요청",
"goalProcess.signOff.requestChangesEffect": "에이전트로 다시 보냅니다. 변경해야 할 내용을 메모에 작성하세요.",
"goalProcess.signOff.sentBack": "변경 요청으로 다시 보냄",
- "goalProcess.stale.description": "{{duration}} 동안 신호가 없습니다. 다음 진행 시 이 시도를 잃어버린 것으로 표시하고 새 시도를 시작합니다 — 실패로 간주되지 않습니다.",
"goalProcess.start": "시작",
"goalProcess.summary.done": "완료됨 · {{count}}번 시도",
"goalProcess.summary.gateOpen": "결정을 기다리는 중",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "실행",
"goalProcess.tabs.result": "전달물",
"goalProcess.tag.done": "완료됨",
- "goalProcess.tag.lost": "잃어버림",
"goalProcess.tag.needsDecision": "결정이 필요함",
"goalProcess.tag.retired": "중단됨",
"goalProcess.tag.verifying": "검증 중",
diff --git a/locales/nl-NL/chat.json b/locales/nl-NL/chat.json
index 0ea5479f04b..4a3b2dc33e1 100644
--- a/locales/nl-NL/chat.json
+++ b/locales/nl-NL/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "Wijzigingen aanvragen",
"goalProcess.signOff.requestChangesEffect": "Stuur het terug naar de agent. Geef aan wat er moet veranderen in de notities.",
"goalProcess.signOff.sentBack": "Teruggestuurd voor wijzigingen",
- "goalProcess.stale.description": "Geen activiteit gedurende {{duration}}. De volgende voortgang markeert deze poging als verloren en start een nieuwe poging — dit telt niet als een mislukking.",
"goalProcess.start": "Start",
"goalProcess.summary.done": "Voltooid · {{count}} pogingen",
"goalProcess.summary.gateOpen": "Wachtend op jouw beslissing",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "Uitvoering",
"goalProcess.tabs.result": "Levering",
"goalProcess.tag.done": "Voltooid",
- "goalProcess.tag.lost": "Verloren",
"goalProcess.tag.needsDecision": "Jouw beslissing is nodig",
"goalProcess.tag.retired": "Afgesloten",
"goalProcess.tag.verifying": "Verifiëren",
diff --git a/locales/pl-PL/chat.json b/locales/pl-PL/chat.json
index 17f305c0143..96a76050567 100644
--- a/locales/pl-PL/chat.json
+++ b/locales/pl-PL/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "Poproś o zmiany",
"goalProcess.signOff.requestChangesEffect": "Wyślij to z powrotem do Agenta. Powiedz, co zmienić w notatkach.",
"goalProcess.signOff.sentBack": "Wysłano z powrotem do zmian",
- "goalProcess.stale.description": "Brak aktywności przez {{duration}}. Kolejny postęp oznaczy tę próbę jako utraconą i rozpocznie nową — nie będzie to liczone jako niepowodzenie.",
"goalProcess.start": "Uruchom",
"goalProcess.summary.done": "Ukończone · {{count}} prób",
"goalProcess.summary.gateOpen": "Oczekuje na Twoją decyzję",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "Wykonanie",
"goalProcess.tabs.result": "Dostarczenie",
"goalProcess.tag.done": "Ukończone",
- "goalProcess.tag.lost": "Utracone",
"goalProcess.tag.needsDecision": "Wymaga Twojej decyzji",
"goalProcess.tag.retired": "Wycofane",
"goalProcess.tag.verifying": "Weryfikacja",
diff --git a/locales/pt-BR/chat.json b/locales/pt-BR/chat.json
index 3205273c088..295332cf7dc 100644
--- a/locales/pt-BR/chat.json
+++ b/locales/pt-BR/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "Solicitar alterações",
"goalProcess.signOff.requestChangesEffect": "Envie de volta para o Agente. Diga o que mudar nas notas.",
"goalProcess.signOff.sentBack": "Enviado de volta para alterações",
- "goalProcess.stale.description": "Sem sinal por {{duration}}. O próximo avanço marcará esta tentativa como perdida e iniciará uma nova — isso não conta como falha.",
"goalProcess.start": "Iniciar",
"goalProcess.summary.done": "Concluído · {{count}} tentativas",
"goalProcess.summary.gateOpen": "Aguardando sua decisão",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "Execução",
"goalProcess.tabs.result": "Entrega",
"goalProcess.tag.done": "Concluído",
- "goalProcess.tag.lost": "Perdido",
"goalProcess.tag.needsDecision": "Precisa da sua decisão",
"goalProcess.tag.retired": "Retirado",
"goalProcess.tag.verifying": "Verificando",
diff --git a/locales/ru-RU/chat.json b/locales/ru-RU/chat.json
index 638c83b0345..178e842db9a 100644
--- a/locales/ru-RU/chat.json
+++ b/locales/ru-RU/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "Запросить изменения",
"goalProcess.signOff.requestChangesEffect": "Отправить обратно агенту. Укажите, что изменить, в заметках.",
"goalProcess.signOff.sentBack": "Отправлено на изменения",
- "goalProcess.stale.description": "Нет активности в течение {{duration}}. Следующее продвижение пометит эту попытку как потерянную и начнет новую — это не будет считаться неудачей.",
"goalProcess.start": "Начать",
"goalProcess.summary.done": "Выполнено · {{count}} попыток",
"goalProcess.summary.gateOpen": "Ожидание вашего решения",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "Выполнение",
"goalProcess.tabs.result": "Результат",
"goalProcess.tag.done": "Выполнено",
- "goalProcess.tag.lost": "Потеряно",
"goalProcess.tag.needsDecision": "Требуется ваше решение",
"goalProcess.tag.retired": "Снято",
"goalProcess.tag.verifying": "Проверка",
diff --git a/locales/tr-TR/chat.json b/locales/tr-TR/chat.json
index d4f745d5852..1ce7caf3d16 100644
--- a/locales/tr-TR/chat.json
+++ b/locales/tr-TR/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "Değişiklik talep et",
"goalProcess.signOff.requestChangesEffect": "Ajan'a geri gönderin. Notlarda neyin değişmesi gerektiğini belirtin.",
"goalProcess.signOff.sentBack": "Değişiklikler için geri gönderildi",
- "goalProcess.stale.description": "{{duration}} süredir bir sinyal yok. Bir sonraki ilerleme bu denemeyi kayıp olarak işaretler ve yeni bir deneme başlatır — bu bir başarısızlık olarak sayılmaz.",
"goalProcess.start": "Başlat",
"goalProcess.summary.done": "Tamamlandı · {{count}} deneme",
"goalProcess.summary.gateOpen": "Kararınızı bekliyor",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "Yürütme",
"goalProcess.tabs.result": "Teslimat",
"goalProcess.tag.done": "Tamamlandı",
- "goalProcess.tag.lost": "Kaybedildi",
"goalProcess.tag.needsDecision": "Kararınıza ihtiyaç var",
"goalProcess.tag.retired": "Emekli edildi",
"goalProcess.tag.verifying": "Doğrulanıyor",
diff --git a/locales/vi-VN/chat.json b/locales/vi-VN/chat.json
index 0174ed8f6cc..a568737bbf3 100644
--- a/locales/vi-VN/chat.json
+++ b/locales/vi-VN/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "Yêu cầu thay đổi",
"goalProcess.signOff.requestChangesEffect": "Gửi lại cho Agent. Nói rõ những gì cần thay đổi trong ghi chú.",
"goalProcess.signOff.sentBack": "Đã gửi lại để thay đổi",
- "goalProcess.stale.description": "Không có tín hiệu trong {{duration}}. Lần tiến hành tiếp theo sẽ đánh dấu lần thử này là thất bại và bắt đầu một lần mới — điều này không được tính là thất bại.",
"goalProcess.start": "Bắt đầu",
"goalProcess.summary.done": "Hoàn thành · {{count}} lần thử",
"goalProcess.summary.gateOpen": "Đang chờ quyết định của bạn",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "Thực thi",
"goalProcess.tabs.result": "Kết quả",
"goalProcess.tag.done": "Hoàn thành",
- "goalProcess.tag.lost": "Mất",
"goalProcess.tag.needsDecision": "Cần quyết định của bạn",
"goalProcess.tag.retired": "Đã nghỉ",
"goalProcess.tag.verifying": "Đang xác minh",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 7fd25fc2924..d90f6d3b8ac 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -986,7 +986,7 @@
"goalProcess.metricDetail.findings.title": "全部结论",
"goalProcess.metricDetail.lifecycle.empty": "还没有记录任何事件",
"goalProcess.metricDetail.lifecycle.title": "活动时间线",
- "goalProcess.metricDetail.liveness.driver": "目标会自主推进:每个任务完成即触发下一步,失联或停滞的任务由兜底扫描捞回。除非有决策门等你,这里没有任何事情需要你干预。",
+ "goalProcess.metricDetail.liveness.driver": "目标会自主推进:每个任务完成即触发下一步,停滞或失去设备的任务由兜底扫描捞回。除非有决策门等你,这里没有任何事情需要你干预。",
"goalProcess.metricDetail.liveness.latest": "最近活动",
"goalProcess.metricDetail.liveness.running": "正在执行",
"goalProcess.metricDetail.liveness.title": "活性",
@@ -1072,6 +1072,9 @@
"goalProcess.planning.title": "正在规划探索方向",
"goalProcess.portal.openPage": "打开目标页",
"goalProcess.portal.title": "目标",
+ "goalProcess.quota.resumeAt": "{{time}} 继续",
+ "goalProcess.quota.resumeSoon": "即将继续",
+ "goalProcess.quota.tooltip": "已达到用量上限。额度恢复后,目标会自动继续这个任务,不计失败次数。",
"goalProcess.requirementPlaceholder": "描述怎样才算达成这个目标…",
"goalProcess.requirementSaveFailed": "验收要求保存失败,下次编辑时会自动重试",
"goalProcess.result.changes.comment": "你的修改意见",
@@ -1194,7 +1197,7 @@
"goalProcess.signOff.requestChanges": "提出修改",
"goalProcess.signOff.requestChangesEffect": "退回给 Agent 重做,在补充说明里写要改什么",
"goalProcess.signOff.sentBack": "已退回修改",
- "goalProcess.stale.description": "已 {{duration}} 没有心跳。下一次推进会把这次尝试标为失联并重开一次,不计失败次数。",
+ "goalProcess.stalled.description": "上次心跳在 {{duration}}。下一次推进会重开这次尝试,不计失败次数。",
"goalProcess.start": "启动",
"goalProcess.summary.done": "完成 · {{count}} 次尝试",
"goalProcess.summary.gateOpen": "等你决定",
@@ -1206,10 +1209,11 @@
"goalProcess.tabs.process": "执行过程",
"goalProcess.tabs.result": "结果交付",
"goalProcess.tag.done": "完成",
- "goalProcess.tag.lost": "失联",
"goalProcess.tag.needsDecision": "等你决定",
"goalProcess.tag.retired": "已放弃",
+ "goalProcess.tag.stalled": "停滞",
"goalProcess.tag.verifying": "验证中",
+ "goalProcess.tag.waitingQuota": "等待额度",
"goalTask.checks": "{{passed}}/{{total}} 项通过",
"goalTask.plan.drafting": "正在拆解任务…",
"goalTask.round": "第 {{current}} 轮",
diff --git a/locales/zh-TW/chat.json b/locales/zh-TW/chat.json
index e148d2a7082..e8cf646979d 100644
--- a/locales/zh-TW/chat.json
+++ b/locales/zh-TW/chat.json
@@ -1178,7 +1178,6 @@
"goalProcess.signOff.requestChanges": "請求更改",
"goalProcess.signOff.requestChangesEffect": "將其發送回代理。請在備註中說明應更改的內容。",
"goalProcess.signOff.sentBack": "已發送回進行更改",
- "goalProcess.stale.description": "{{duration}} 未收到心跳信號。下一次推進將標記此嘗試為丟失並啟動新嘗試 — 這不算作失敗。",
"goalProcess.start": "開始",
"goalProcess.summary.done": "已完成 · {{count}} 次嘗試",
"goalProcess.summary.gateOpen": "等待您的決定",
@@ -1190,7 +1189,6 @@
"goalProcess.tabs.process": "執行",
"goalProcess.tabs.result": "交付",
"goalProcess.tag.done": "已完成",
- "goalProcess.tag.lost": "已丟失",
"goalProcess.tag.needsDecision": "需要您的決定",
"goalProcess.tag.retired": "已退役",
"goalProcess.tag.verifying": "驗證中",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index 4a84315cb59..ca0b8b6ad8c 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -2515,7 +2515,8 @@ export default {
'goalProcess.acceptance.errored': 'Verification error',
'goalProcess.acceptance.rejected': 'Rejected',
'goalProcess.tag.verifying': 'Verifying',
- 'goalProcess.tag.lost': 'Lost',
+ 'goalProcess.tag.stalled': 'Stalled',
+ 'goalProcess.tag.waitingQuota': 'Waiting for quota',
'goalProcess.tag.done': 'Done',
'goalProcess.tag.retired': 'Retired',
'goalProcess.gate.decisionPointLabel': 'What needs your decision',
@@ -2651,8 +2652,12 @@ export default {
'goalProcess.attempts.failed': 'Did not pass',
'goalProcess.attempts.retired': 'Retired',
'goalProcess.attempts.running': 'Running',
- 'goalProcess.stale.description':
- 'No heartbeat for {{duration}}. The next advance marks this attempt lost and starts a fresh one — it does not count as a failure.',
+ 'goalProcess.stalled.description':
+ 'Last heartbeat {{duration}}. The next advance restarts this attempt — it does not count as a failure.',
+ 'goalProcess.quota.resumeAt': 'Resumes {{time}}',
+ 'goalProcess.quota.resumeSoon': 'Resuming soon',
+ 'goalProcess.quota.tooltip':
+ 'The usage limit was reached. The goal resumes this task on its own once the quota resets — it does not count as a failure.',
'goalProcess.running.elapsed': 'Running {{duration}}',
'goalProcess.graph.title': 'Exploration map',
'goalProcess.graph.view.stage': 'Current stage',
diff --git a/packages/types/src/goal.ts b/packages/types/src/goal.ts
index 499277fbf00..08738c5b5b5 100644
--- a/packages/types/src/goal.ts
+++ b/packages/types/src/goal.ts
@@ -785,6 +785,13 @@ export interface GoalGraphSnapshot {
events: GoalGraphEvent[];
goal: GoalItem;
nodes: GoalGraphNode[];
+ /**
+ * When the coordinator retries each active task node a usage window refused
+ * (the reset plus its safety margin). Such a Task is held `paused` with no
+ * running run, so it has no heartbeat — without this the client reads the
+ * wait as lost.
+ */
+ quotaRetryAt?: Record<string, Date>;
/**
* The wrap-up report: whether it is being written, done or failed, and the
* newest submitted version. Absent until the Goal-level acceptance has ended
diff --git a/src/features/AgentGoals/ProcessControl/Frontier.test.tsx b/src/features/AgentGoals/ProcessControl/Frontier.test.tsx
new file mode 100644
index 00000000000..09bf7ff04e4
--- /dev/null
+++ b/src/features/AgentGoals/ProcessControl/Frontier.test.tsx
@@ -0,0 +1,87 @@
+/**
+ * @vitest-environment happy-dom
+ */
+import type { GoalGraphNode, GoalGraphSnapshot, GoalItem } from '@lobechat/types';
+import { render, screen } from '@testing-library/react';
+import { describe, expect, it, vi } from 'vitest';
+
+import Frontier from './Frontier';
+import { buildGoalGraphView } from './goalGraphViewModel';
+
+vi.mock('@/store/chat', () => ({
+ useChatStore: (selector: (state: Record<string, unknown>) => unknown) =>
+ selector({ openAcceptance: vi.fn() }),
+}));
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({ i18n: { language: 'en-US' }, t: (key: string) => key }),
+}));
+
+const T0 = new Date('2026-08-01T00:00:00Z');
+const at = (minutes: number) => new Date(T0.getTime() + minutes * 60_000);
+
+const goal = {
+ config: { recovery: { operationLeaseTimeoutMs: 15 * 60_000 } },
+ createdAt: T0,
+ id: 'goal-1',
+ status: 'running',
+ title: 'Goal',
+ updatedAt: T0,
+} as unknown as GoalItem;
+
+const task = {
+ createdAt: at(1),
+ goalId: 'goal-1',
+ id: 'w1',
+ kind: 'task',
+ priority: 0,
+ status: 'active',
+ taskId: 'task-1',
+ title: 'Build the share page',
+ updatedAt: at(30),
+} as unknown as GoalGraphNode;
+
+const snapshot: GoalGraphSnapshot = {
+ decisions: [],
+ edges: [],
+ events: [
+ {
+ actorId: null,
+ actorType: 'system',
+ createdAt: at(30),
+ entityId: 'w1',
+ entityType: 'node',
+ eventType: 'activated',
+ goalId: 'goal-1',
+ id: 'e1',
+ operationId: null,
+ reason: null,
+ taskId: 'task-1',
+ },
+ ],
+ goal,
+ nodes: [task],
+ workVersions: [],
+} as unknown as GoalGraphSnapshot;
+
+describe('Frontier stalled row', () => {
+ it('explains the stall without an attempt ledger that still says the attempt is running', () => {
+ const graph = buildGoalGraphView(snapshot, at(240).getTime());
+ expect(graph.frontier[0]).toMatchObject({ kind: 'stale' });
+
+ render(
+ <Frontier
+ actions={{ addTask: vi.fn(), decide: vi.fn() }}
+ canEdit={false}
+ graph={graph}
+ onSelect={vi.fn()}
+ />,
+ );
+
+ expect(screen.getByText('goalProcess.tag.stalled')).toBeTruthy();
+ expect(screen.getByText('goalProcess.stalled.description')).toBeTruthy();
+ // The open attempt reads "Running" under a "Stalled" badge — a contradiction
+ // the reader cannot resolve, and the description already says what happened.
+ expect(screen.queryByText('goalProcess.attempts.title')).toBeNull();
+ });
+});
diff --git a/src/features/AgentGoals/ProcessControl/Frontier.tsx b/src/features/AgentGoals/ProcessControl/Frontier.tsx
index dc6b6bf9690..dab91636f61 100644
--- a/src/features/AgentGoals/ProcessControl/Frontier.tsx
+++ b/src/features/AgentGoals/ProcessControl/Frontier.tsx
@@ -37,6 +37,7 @@ import {
} from './coordinatorCopy';
import type { FrontierItem, GoalGraphView, GoalNodeView } from './goalGraphViewModel';
import ReleaseGateEntry from './ReleaseGateEntry';
+import { TASK_HOLD_VISUALS, useQuotaResumeText } from './taskHold';
import { useElapsed } from './useElapsed';
/**
@@ -172,8 +173,17 @@ const RowGlyph = memo<{ kind: FrontierItem['kind']; view: GoalNodeView }>(({ kin
case 'stale': {
return (
<Icon
- color={TASK_STATUS_VISUALS.failed.color}
- icon={TASK_STATUS_VISUALS.failed.icon}
+ color={TASK_HOLD_VISUALS.stalled.color}
+ icon={TASK_HOLD_VISUALS.stalled.icon}
+ size={16}
+ />
+ );
+ }
+ case 'quota': {
+ return (
+ <Icon
+ color={TASK_HOLD_VISUALS.waitingQuota.color}
+ icon={TASK_HOLD_VISUALS.waitingQuota.icon}
size={16}
/>
);
@@ -262,6 +272,19 @@ const RunningClock = memo<{ startedAt?: Date }>(({ startedAt }) => {
RunningClock.displayName = 'GoalRunningClock';
+const QuotaResumeTime = memo<{ retryAt?: Date }>(({ retryAt }) => {
+ const { t } = useTranslation('chat');
+ const text = useQuotaResumeText(retryAt);
+ if (!text) return null;
+ return (
+ <Text fontSize={12} title={t('goalProcess.quota.tooltip')} type={'secondary'}>
+ {text}
+ </Text>
+ );
+});
+
+QuotaResumeTime.displayName = 'GoalQuotaResumeTime';
+
const DoneTime = memo<{ view: GoalNodeView }>(({ view }) => {
const { text, title } = useActivityTime(view.node.resolvedAt ?? view.node.updatedAt);
return (
@@ -278,7 +301,7 @@ const StaleBody = memo<{ view: GoalNodeView }>(({ view }) => {
const { text } = useActivityTime(view.heartbeatAt);
return (
<Text fontSize={13} type={'secondary'}>
- {t('goalProcess.stale.description', { duration: text })}
+ {t('goalProcess.stalled.description', { duration: text })}
</Text>
);
});
@@ -505,16 +528,18 @@ const FrontierRow = memo<{
? null
: { color: 'info', text: t('goalProcess.tag.verifying') }
: item.kind === 'stale'
- ? { color: 'error', text: t('goalProcess.tag.lost') }
- : item.kind === 'done'
- ? {
- color: undefined,
- text:
- node.status === 'resolved'
- ? t('goalProcess.tag.done')
- : t('goalProcess.tag.retired'),
- }
- : null;
+ ? { color: 'warning', text: t('goalProcess.tag.stalled') }
+ : item.kind === 'quota'
+ ? { color: 'warning', text: t('goalProcess.tag.waitingQuota') }
+ : item.kind === 'done'
+ ? {
+ color: undefined,
+ text:
+ node.status === 'resolved'
+ ? t('goalProcess.tag.done')
+ : t('goalProcess.tag.retired'),
+ }
+ : null;
return (
<Block
@@ -545,6 +570,7 @@ const FrontierRow = memo<{
<Flexbox horizontal align={'center'} gap={8} style={{ flex: 'none' }}>
<AcceptanceChip view={view} />
{item.kind === 'running' && <RunningClock startedAt={view.startedAt} />}
+ {item.kind === 'quota' && <QuotaResumeTime retryAt={view.quotaRetryAt} />}
{item.kind === 'done' && <DoneTime view={view} />}
</Flexbox>
</Flexbox>
@@ -570,8 +596,13 @@ const FrontierRow = memo<{
{node.description}
</Text>
)}
- {item.kind === 'stale' && <StaleBody view={view} />}
- <AttemptLedger view={subject ?? view} />
+ {item.kind === 'stale' ? (
+ // The open attempt would read "Running" under a "Stalled" badge; the
+ // body already says when it went quiet and what happens next.
+ <StaleBody view={view} />
+ ) : (
+ <AttemptLedger view={subject ?? view} />
+ )}
</Flexbox>
)}
</Block>
diff --git a/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsx b/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsx
index 41a8077ac50..5c9a28348f0 100644
--- a/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsx
+++ b/src/features/AgentGoals/ProcessControl/Graph/GraphNode.tsx
@@ -16,6 +16,7 @@ import AssigneeProfileAvatar from '../AssigneeProfileAvatar';
import { coordinatorNodeTitleKey } from '../coordinatorCopy';
import type { GoalNodeView } from '../goalGraphViewModel';
import { KIND_COLOR, KIND_ICON } from '../shared';
+import { TASK_HOLD_VISUALS } from '../taskHold';
import { useElapsed } from '../useElapsed';
import { experimentStatusVisual } from './experimentStatus';
@@ -206,7 +207,7 @@ const styles = createStaticStyles(({ css }) => ({
border-color: ${cssVar.colorPrimaryBorder};
`,
stale: css`
- border-color: ${cssVar.colorErrorBorder};
+ border-color: ${cssVar.colorWarningBorder};
`,
subtitle: css`
overflow: hidden;
@@ -259,12 +260,9 @@ const useStateChip = (data: GraphNodeData): StateChip | null => {
icon: TASK_STATUS_VISUALS.paused.icon,
text: t('goalProcess.tag.needsDecision'),
};
- if (stale)
- return {
- color: TASK_STATUS_VISUALS.failed.color,
- icon: TASK_STATUS_VISUALS.failed.icon,
- text: t('goalProcess.tag.lost'),
- };
+ if (stale) return { ...TASK_HOLD_VISUALS.stalled, text: t('goalProcess.tag.stalled') };
+ if (view.quotaRetryAt)
+ return { ...TASK_HOLD_VISUALS.waitingQuota, text: t('goalProcess.tag.waitingQuota') };
// Running renders the same animated ring the frontier and home surfaces use.
if (running)
return { color: TASK_STATUS_VISUALS.running.color, text: t('goalProcess.node.running') };
diff --git a/src/features/AgentGoals/ProcessControl/Graph/batchModel.ts b/src/features/AgentGoals/ProcessControl/Graph/batchModel.ts
index f9989b396a7..6457bb35a75 100644
--- a/src/features/AgentGoals/ProcessControl/Graph/batchModel.ts
+++ b/src/features/AgentGoals/ProcessControl/Graph/batchModel.ts
@@ -150,7 +150,8 @@ export const batchCellState = (
if (status === 'resolved') return 'done';
if (status === 'waiting' || view.decision || view.isStale || waitingOn.has(view.node.id))
return 'human';
- if (isRunningNode(view)) return 'running';
+ // Held for a usage window to reopen: still in flight, resumes on its own.
+ if (isRunningNode(view) || view.quotaRetryAt) return 'running';
return 'backlog';
};
diff --git a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts
index 290507127b2..9924ac97c2d 100644
--- a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts
+++ b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.test.ts
@@ -206,7 +206,28 @@ describe('buildGoalGraphView', () => {
expect(view.byId.w1.isStale).toBe(true);
expect(view.frontier[0]).toMatchObject({ kind: 'stale', rank: 0 });
- expect(view.needsYou).toBe(1);
+ // It leads the list, but the coordinator restarts it on its own.
+ expect(view.needsYou).toBe(0);
+ });
+
+ it('reads a task held for a usage window as waiting for quota, not stalled', () => {
+ // The coordinator holds a refused Task until the reset and wakes itself up
+ // then. Its run has ended, so the heartbeat outlives the lease — read as a
+ // stall, the page put a failure badge and "needs you" on a Task that
+ // resumes by itself.
+ const view = buildGoalGraphView(
+ snapshot({
+ events: [event('w1', 'activated', 30)],
+ nodes: [node('w1', { status: 'active', taskId: 'task-1', updatedAt: at(30) })],
+ quotaRetryAt: { w1: at(180) },
+ }),
+ NOW,
+ );
+
+ expect(view.byId.w1).toMatchObject({ isStale: false, quotaRetryAt: at(180) });
+ expect(isRunningNode(view.byId.w1)).toBe(false);
+ expect(view.frontier[0]).toMatchObject({ kind: 'quota', rank: 1 });
+ expect(view.needsYou).toBe(0);
});
it('reads a delivered task as verifying, not lost, while the judgment settles', () => {
diff --git a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts
index ad7d3a36b5e..0b31a13c600 100644
--- a/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts
+++ b/src/features/AgentGoals/ProcessControl/goalGraphViewModel.ts
@@ -144,13 +144,21 @@ export interface GoalNodeView {
heartbeatAt: Date;
/** Decisions on this node a human already resolved. */
humanTouches: GoalGraphDecision[];
- /** Active for longer than the lease window with no heartbeat — the coordinator would reclaim it. */
+ /**
+ * Active for longer than the lease window with no heartbeat — the coordinator
+ * would reclaim it. Never set while the Task waits out a usage window.
+ */
isStale: boolean;
/** Delivered and waiting for its Acceptance judgment to settle. */
isVerifying: boolean;
node: GoalGraphNode;
/** The Task that produced this finding. */
producedBy?: GoalGraphNode;
+ /**
+ * When the coordinator retries a Task a usage window refused. The Task is
+ * held on purpose, so it is neither running nor stalled.
+ */
+ quotaRetryAt?: Date;
/** Stable 1-based number over task nodes in graph creation order. */
seq?: number;
/** When the current attempt started, for the running clock. */
@@ -196,7 +204,7 @@ export const hasReviewableResult = (view: GoalNodeView): boolean => {
*/
export const isRunningNode = (view: GoalNodeView): boolean => {
if (view.node.kind === 'problem') return false;
- return view.node.status === 'active' && !view.isStale && !view.halted;
+ return view.node.status === 'active' && !view.isStale && !view.halted && !view.quotaRetryAt;
};
/** A goal in one of these states runs nothing, whatever its nodes still say. */
@@ -204,7 +212,8 @@ const CLOSED_GOAL_STATUSES = new Set<string>(['achieved', 'canceled', 'failed'])
/** Ended by a person or by success: `GoalService.decide` refuses gates until a reopen. */
const GOAL_ENDED_STATUSES = new Set<string>(['achieved', 'canceled']);
-export type FrontierItemKind = 'gate' | 'stale' | 'verifying' | 'running' | 'ready' | 'done';
+export type FrontierItemKind =
+ 'gate' | 'stale' | 'quota' | 'verifying' | 'running' | 'ready' | 'done';
export interface FrontierItem {
key: string;
@@ -343,6 +352,7 @@ export const buildGoalGraphView = (
events,
goal,
nodes,
+ quotaRetryAt: quotaRetryAtByNode,
report,
runHeartbeats,
spend,
@@ -453,6 +463,13 @@ export const buildGoalGraphView = (
node.kind === 'task' &&
live &&
(acceptanceVerifying || (!!delivered && now - delivered.getTime() <= VERIFY_SETTLE_GRACE_MS));
+ // A usage window refused the run and the coordinator holds the Task until it
+ // reopens. Its run has ended, so the heartbeat ages past the lease while
+ // nothing is wrong — read as lost, it showed a failure badge on a Task that
+ // resumes by itself.
+ const quotaRetry = quotaRetryAtByNode?.[node.id];
+ const quotaRetryAt =
+ node.kind === 'task' && live && !isVerifying && quotaRetry ? new Date(quotaRetry) : undefined;
return {
answers: supportsByFinding.get(node.id) ?? [],
@@ -477,11 +494,17 @@ export const buildGoalGraphView = (
gateSubjectId: gateSubject.get(node.id),
heartbeatAt,
humanTouches: nodeDecisions.filter((d) => d.status === 'resolved' && !!d.resolvedByUserId),
- isStale: node.kind === 'task' && live && !isVerifying && now - heartbeatAt.getTime() > lease,
+ isStale:
+ node.kind === 'task' &&
+ live &&
+ !isVerifying &&
+ !quotaRetryAt &&
+ now - heartbeatAt.getTime() > lease,
isVerifying,
...(halted ? { halted } : {}),
node,
producedBy: producedByFinding.get(node.id),
+ ...(quotaRetryAt ? { quotaRetryAt } : {}),
seq: node.kind === 'experiment' ? ++experimentSeq : node.kind === 'task' ? ++seq : undefined,
startedAt: isRunningAttempt ? open.startedAt : undefined,
};
@@ -507,7 +530,13 @@ export const buildGoalGraphView = (
if (goalClosed) continue;
frontier.push({
key: node.id,
- kind: view.isStale ? 'stale' : view.isVerifying ? 'verifying' : 'running',
+ kind: view.isStale
+ ? 'stale'
+ : view.quotaRetryAt
+ ? 'quota'
+ : view.isVerifying
+ ? 'verifying'
+ : 'running',
rank: view.isStale ? 0 : 1,
view,
});
@@ -546,7 +575,9 @@ export const buildGoalGraphView = (
findings: views.filter((view) => view.node.kind === 'finding'),
frontier: [...done, ...frontier],
goal,
- needsYou: frontier.filter((item) => item.rank === 0).length,
+ // A stalled Task leads the list, but the coordinator restarts it on its own:
+ // only a gate actually waits on the person.
+ needsYou: frontier.filter((item) => item.kind === 'gate').length,
nodes: views,
report,
spend,
diff --git a/src/features/AgentGoals/ProcessControl/taskHold.ts b/src/features/AgentGoals/ProcessControl/taskHold.ts
new file mode 100644
index 00000000000..e48e5277f22
--- /dev/null
+++ b/src/features/AgentGoals/ProcessControl/taskHold.ts
@@ -0,0 +1,30 @@
+import { cssVar } from '@lobehub/ui';
+import { TriangleAlert } from 'lucide-react';
+import { useTranslation } from 'react-i18next';
+
+import { type ExecutionStatusVisual, TASK_STATUS_VISUALS } from '@/components/ExecutionStatus';
+
+/**
+ * A Task the coordinator holds without anyone needing to act: either its run
+ * went quiet past the lease (it restarts on the next advance) or a usage window
+ * refused it (it resumes after the reset). Neither is a failure, so neither
+ * borrows the failed red cross.
+ */
+export const TASK_HOLD_VISUALS = {
+ stalled: { color: cssVar.colorWarning, icon: TriangleAlert },
+ waitingQuota: TASK_STATUS_VISUALS.scheduled,
+} satisfies Record<string, ExecutionStatusVisual>;
+
+/** "Resumes Sat 00:20", or "Resuming soon" once the reset has passed. */
+export const useQuotaResumeText = (retryAt?: Date): string | undefined => {
+ const { t, i18n } = useTranslation('chat');
+ if (!retryAt) return;
+ if (retryAt.getTime() <= Date.now()) return t('goalProcess.quota.resumeSoon');
+
+ const time = new Intl.DateTimeFormat(i18n.resolvedLanguage || i18n.language || undefined, {
+ hour: 'numeric',
+ minute: '2-digit',
+ weekday: 'short',
+ }).format(retryAt);
+ return t('goalProcess.quota.resumeAt', { time });
+};
diff --git a/src/features/Conversation/Messages/GoalTaskCard/PlanChain.tsx b/src/features/Conversation/Messages/GoalTaskCard/PlanChain.tsx
index d5af5ef032b..31fd49c904b 100644
--- a/src/features/Conversation/Messages/GoalTaskCard/PlanChain.tsx
+++ b/src/features/Conversation/Messages/GoalTaskCard/PlanChain.tsx
@@ -6,6 +6,7 @@ import { Fragment, memo } from 'react';
import { useTranslation } from 'react-i18next';
import { TASK_STATUS_VISUALS } from '@/components/ExecutionStatus';
+import { TASK_HOLD_VISUALS } from '@/features/AgentGoals/ProcessControl/taskHold';
import RunningGlyph from '@/features/Home/components/RunningGlyph';
import { shinyTextStyles } from '@/styles';
@@ -25,12 +26,6 @@ const STEP_VISUAL: Record<
icon: TASK_STATUS_VISUALS.failed.icon,
labelKey: 'goalTask.status.error',
},
- lost: {
- color: TASK_STATUS_VISUALS.failed.color,
- icon: TASK_STATUS_VISUALS.failed.icon,
- labelKey: 'goalProcess.tag.lost',
- open: true,
- },
queued: {
color: TASK_STATUS_VISUALS.backlog.color,
icon: TASK_STATUS_VISUALS.backlog.icon,
@@ -47,6 +42,11 @@ const STEP_VISUAL: Record<
labelKey: 'goalProcess.node.running',
open: true,
},
+ stalled: {
+ ...TASK_HOLD_VISUALS.stalled,
+ labelKey: 'goalProcess.tag.stalled',
+ open: true,
+ },
stopped: {
color: TASK_STATUS_VISUALS.canceled.color,
icon: TASK_STATUS_VISUALS.canceled.icon,
@@ -64,6 +64,11 @@ const STEP_VISUAL: Record<
labelKey: 'goalProcess.node.waiting',
open: true,
},
+ waitingQuota: {
+ ...TASK_HOLD_VISUALS.waitingQuota,
+ labelKey: 'goalProcess.tag.waitingQuota',
+ open: true,
+ },
};
const styles = createStaticStyles(({ css }) => ({
diff --git a/src/features/Conversation/Messages/GoalTaskCard/goalCardModel.test.ts b/src/features/Conversation/Messages/GoalTaskCard/goalCardModel.test.ts
index 58800c7b402..dd88d03647a 100644
--- a/src/features/Conversation/Messages/GoalTaskCard/goalCardModel.test.ts
+++ b/src/features/Conversation/Messages/GoalTaskCard/goalCardModel.test.ts
@@ -94,12 +94,21 @@ describe('buildGoalCardModel', () => {
expect(model).toMatchObject({ findingCount: 1, taskDone: 1, taskTotal: 3, totalCost: 0.23 });
});
- it('marks a task whose run went silent as lost', () => {
+ it('marks a task whose run went silent as stalled', () => {
const model = build({
nodes: [node({ status: 'active', taskId: 'task-1', updatedAt: at(10) })],
});
- expect(model.steps[0].state).toBe('lost');
+ expect(model.steps[0].state).toBe('stalled');
+ });
+
+ it('marks a task held for a usage window as waiting for quota', () => {
+ const model = build({
+ nodes: [node({ id: 'n1', status: 'active', taskId: 'task-1', updatedAt: at(10) })],
+ quotaRetryAt: { n1: at(200) },
+ });
+
+ expect(model.steps[0].state).toBe('waitingQuota');
});
it('shows a task the goal ended under as stopped, not running', () => {
diff --git a/src/features/Conversation/Messages/GoalTaskCard/goalCardModel.ts b/src/features/Conversation/Messages/GoalTaskCard/goalCardModel.ts
index 6b25f9679ad..f338d8a3b55 100644
--- a/src/features/Conversation/Messages/GoalTaskCard/goalCardModel.ts
+++ b/src/features/Conversation/Messages/GoalTaskCard/goalCardModel.ts
@@ -18,13 +18,14 @@ export type GoalCardTone = 'active' | 'canceled' | 'error' | 'paused' | 'waiting
export type PlanStepState =
| 'done'
| 'failed'
- | 'lost'
| 'queued'
| 'retired'
| 'running'
+ | 'stalled'
| 'stopped'
| 'verifying'
- | 'waiting';
+ | 'waiting'
+ | 'waitingQuota';
export interface PlanStep {
id: string;
@@ -64,7 +65,8 @@ export const planStepState = (view: GoalNodeView): PlanStepState => {
if (view.decision) return 'waiting';
if (status === 'active') {
if (view.isVerifying) return 'verifying';
- if (view.isStale) return 'lost';
+ if (view.isStale) return 'stalled';
+ if (view.quotaRetryAt) return 'waitingQuota';
return 'running';
}
if (status === 'waiting' || view.blockers.length > 0) return 'waiting';
diff --git a/src/features/Portal/GoalMetric/Body.tsx b/src/features/Portal/GoalMetric/Body.tsx
index 304ee98b6b2..39f9b94af36 100644
--- a/src/features/Portal/GoalMetric/Body.tsx
+++ b/src/features/Portal/GoalMetric/Body.tsx
@@ -22,6 +22,7 @@ import {
type GoalNodeView,
} from '@/features/AgentGoals/ProcessControl/goalGraphViewModel';
import { KindDot } from '@/features/AgentGoals/ProcessControl/shared';
+import { TASK_HOLD_VISUALS } from '@/features/AgentGoals/ProcessControl/taskHold';
import { formatElapsed, useElapsed } from '@/features/AgentGoals/ProcessControl/useElapsed';
import AssigneeAvatar from '@/features/AgentTasks/features/AssigneeAvatar';
import { formatTaskItemDate } from '@/features/AgentTasks/features/formatTaskItemDate';
@@ -178,9 +179,10 @@ TaskStartDate.displayName = 'GoalMetricTaskStartDate';
const STATE_VISUAL = {
decision: TASK_STATUS_VISUALS.paused,
done: TASK_STATUS_VISUALS.completed,
- lost: TASK_STATUS_VISUALS.failed,
queued: TASK_STATUS_VISUALS.backlog,
retired: TASK_STATUS_VISUALS.canceled,
+ stalled: TASK_HOLD_VISUALS.stalled,
+ waitingQuota: TASK_HOLD_VISUALS.waitingQuota,
} as const satisfies Record<Exclude<TaskRowState, 'running'>, unknown>;
/**
diff --git a/src/features/Portal/GoalMetric/taskRowState.test.ts b/src/features/Portal/GoalMetric/taskRowState.test.ts
index 8cfe3c1e36f..655cc1b5efa 100644
--- a/src/features/Portal/GoalMetric/taskRowState.test.ts
+++ b/src/features/Portal/GoalMetric/taskRowState.test.ts
@@ -28,16 +28,25 @@ describe('taskRowState', () => {
expect(taskRowSpan(running)).toEqual({ endedAt: undefined, startedAt: STARTED });
});
- it('reads a stale active task as lost and freezes its clock at the last heartbeat', () => {
+ it('reads a stale active task as stalled and freezes its clock at the last heartbeat', () => {
const stale = view({ isStale: true });
const state = taskRowState(stale);
- expect(state).toBe('lost');
- // The node row still says `active`; the label must follow the lost glyph, not "Running".
- expect(taskRowStateLabelKey(stale, state)).toBe('goalProcess.tag.lost');
+ expect(state).toBe('stalled');
+ // The node row still says `active`; the label must follow the stalled glyph, not "Running".
+ expect(taskRowStateLabelKey(stale, state)).toBe('goalProcess.tag.stalled');
expect(taskRowSpan(stale)).toEqual({ endedAt: HEARTBEAT, startedAt: STARTED });
});
+ it('reads a task held for a usage window as waiting for quota, not running', () => {
+ const held = view({ quotaRetryAt: ENDED });
+ const state = taskRowState(held);
+
+ expect(state).toBe('waitingQuota');
+ expect(taskRowStateLabelKey(held, state)).toBe('goalProcess.tag.waitingQuota');
+ expect(taskRowSpan(held)?.endedAt).toEqual(HEARTBEAT);
+ });
+
it('freezes the clock of a task parked on a decision', () => {
const parked = view({ decision: { id: 'd1' } as GoalNodeView['decision'] });
const state = taskRowState(parked);
diff --git a/src/features/Portal/GoalMetric/taskRowState.ts b/src/features/Portal/GoalMetric/taskRowState.ts
index dcb47b9ca49..6608234f0b8 100644
--- a/src/features/Portal/GoalMetric/taskRowState.ts
+++ b/src/features/Portal/GoalMetric/taskRowState.ts
@@ -7,12 +7,14 @@ import {
* What one All-tasks row says about its Task. The glyph, its hover label and
* whether the duration clock ticks all read this one value, so the icon, the
* word and the clock can never disagree — an `active` node that lost its lease
- * is `lost`, not "Running".
+ * is `stalled`, not "Running".
*/
-export type TaskRowState = 'decision' | 'done' | 'lost' | 'queued' | 'retired' | 'running';
+export type TaskRowState =
+ 'decision' | 'done' | 'queued' | 'retired' | 'running' | 'stalled' | 'waitingQuota';
export const taskRowState = (view: GoalNodeView): TaskRowState => {
- if (view.isStale) return 'lost';
+ if (view.isStale) return 'stalled';
+ if (view.quotaRetryAt) return 'waitingQuota';
if (view.decision) return 'decision';
if (isRunningNode(view)) return 'running';
if (view.node.status === 'resolved') return 'done';
@@ -21,7 +23,8 @@ export const taskRowState = (view: GoalNodeView): TaskRowState => {
};
export const taskRowStateLabelKey = (view: GoalNodeView, state: TaskRowState) => {
- if (state === 'lost') return 'goalProcess.tag.lost' as const;
+ if (state === 'stalled') return 'goalProcess.tag.stalled' as const;
+ if (state === 'waitingQuota') return 'goalProcess.tag.waitingQuota' as const;
if (state === 'decision') return 'goalProcess.tag.needsDecision' as const;
return `goalProcess.nodeStatus.${view.node.status}` as const;
};