feat: auto-suspend tasks on quota errors, add Claude progress tracking
- Auto-suspend tasks after 3 consecutive quota/auth errors with retry-after date parsing and Discord notification - Add tool_progress and tool_use_summary streaming from Claude Agent SDK - Prefix progress messages with invisible marker so bots ignore them - Fix misleading provider label in codex service logs
This commit is contained in:
@@ -29,6 +29,11 @@ import {
|
||||
} from './group-folder.js';
|
||||
import { logger } from './logger.js';
|
||||
import { createTaskStatusTracker } from './task-status-tracker.js';
|
||||
import {
|
||||
evaluateTaskSuspension,
|
||||
formatSuspensionNotice,
|
||||
suspendTask,
|
||||
} from './task-suspension.js';
|
||||
import {
|
||||
getTaskQueueJid,
|
||||
getTaskRuntimeTaskId,
|
||||
@@ -305,8 +310,31 @@ async function runTask(
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear suspension on success
|
||||
if (!error && currentTask.suspended_until) {
|
||||
updateTask(task.id, { suspended_until: null });
|
||||
}
|
||||
|
||||
// Check for repeated quota/auth errors → auto-suspend
|
||||
let suspended = false;
|
||||
if (error) {
|
||||
const suspension = evaluateTaskSuspension(currentTask, error);
|
||||
if (suspension.suspended && suspension.suspendedUntil) {
|
||||
suspended = true;
|
||||
suspendTask(task.id, suspension.suspendedUntil);
|
||||
const notice = formatSuspensionNotice(
|
||||
currentTask,
|
||||
suspension.suspendedUntil,
|
||||
suspension.reason || error.slice(0, 200),
|
||||
);
|
||||
await deps.sendMessage(task.chat_jid, notice);
|
||||
}
|
||||
}
|
||||
|
||||
if (error && !suspended) {
|
||||
await statusTracker.update('retrying', nextRun);
|
||||
} else if (suspended) {
|
||||
// Don't update status tracker — task is suspended, not retrying
|
||||
} else if (nextRun) {
|
||||
await statusTracker.update('waiting', nextRun);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user