fix: alignment hold also covers scheduled-task limits and the primer

- A scheduled Claude task that hits the usage limit now extends the
  alignment hold to the next slot when the reset is off the grid, like a
  room turn (it called runAgentProcess directly and skipped that path).
- The Claude primer is skipped while a hold outlasts its slot (e.g. the
  08:00 primer during a realignment hold until 13:00). A hold ending at
  the slot itself does not count: the slot timer fired at 07:59:59.999
  for 08:00 on 2026-10-16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codex
2026-10-16 13:04:44 +09:00
parent a2b9898c0b
commit 0a5436e4ad
6 changed files with 155 additions and 6 deletions

View File

@@ -22,12 +22,11 @@ import {
} from './claude-usage-pause.js';
import { getPairedTaskById } from './db.js';
import {
extendUsageAlignmentHold,
formatUsageAlignmentHoldMessage,
formatUsageLimitAlignedPauseMessage,
getUsageAlignmentHold,
holdUntilSlotAfterLimitReset,
isUsageAlignmentBypassed,
nextWindowStartAfterOffSlotReset,
} from './usage-alignment-hold.js';
import { completePairedTaskWithReason } from './paired-task-status.js';
import { prepareMessageAgentExecutionTarget } from './message-agent-executor-target.js';
@@ -126,10 +125,7 @@ async function pauseRunForClaudeUsage(args: {
} else {
// A limit that resets off the slot grid would open an off-slot window
// on the first request after the reset; hold until the next slot.
if (pause.resetKnown) {
const slot = nextWindowStartAfterOffSlotReset(pause.until);
if (slot) extendUsageAlignmentHold(slot);
}
if (pause.resetKnown) holdUntilSlotAfterLimitReset(pause.until);
const holdAtReset = pause.resetKnown
? getUsageAlignmentHold(pause.until.getTime())
: null;