refactor: replace the Claude→Codex failover with a usage-limit notice
When Claude hit a limit the run was handed to a Codex service (codex-main/codex-review) through service_handoffs and a global owner failover. That service does not exist in this deployment, so handoffs stayed pending forever (2 rows since May) and the user got no answer. Removed: - handoff creation (message-agent-executor-handoff, paired-turn-fallback) and the delegated paired-execution path - the pending-handoff poll/claim worker (message-runtime-handoffs) and the service_handoffs CRUD module (db/service-handoffs, db exports) - global owner failover in service-routing, its recovery timer in index, the dashboard failover line, the codex-review failover prompt pack and prompts/codex-review-failover-platform.md - failoverOwner in RoomRoleContext and the `failover=` ROOM_ROLE field - OWNER_/REVIEWER_/ARBITER_FALLBACK_ENABLED and FAILOVER_MIN_DURATION_MS - tests for the removed behaviour Now, when a Claude run fails with a usage/rate limit (trigger reason 429 or usage-exhausted) the executor closes the open paired task as completed/claude_usage_limit and sends the room one final notice: "Claude 사용 한도에 도달했습니다. 21:40에 재개할 수 있습니다." The reset time comes from the error text (CLI banner "resets 9:40pm (Asia/Seoul)", dated banners, "try again at ...", ISO timestamps), else from the cached usage API window at 100%, else "잠시 후 다시 시도해 주세요". Nothing retries silently; the next user message starts a new task. Other Claude failures (session failure, org access denied) now end as ordinary run errors. The service_handoffs table, its columns on paired_turn_attempts and the migrations stay untouched for the later migration squash; the runtime no longer reads or writes them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -167,8 +167,11 @@ describe('evaluateStreamedOutput', () => {
|
||||
claudeOpts,
|
||||
);
|
||||
expect(result.shouldForwardOutput).toBe(false);
|
||||
expect(result.newTrigger).toEqual({ reason: 'usage-exhausted' });
|
||||
expect(result.state.streamedTriggerReason).toEqual({
|
||||
expect(result.newTrigger).toEqual({
|
||||
reason: 'usage-exhausted',
|
||||
message: "You're out of extra usage. Resets at 5pm.",
|
||||
});
|
||||
expect(result.state.streamedTriggerReason).toMatchObject({
|
||||
reason: 'usage-exhausted',
|
||||
});
|
||||
});
|
||||
@@ -214,8 +217,8 @@ describe('evaluateStreamedOutput', () => {
|
||||
claudeOpts,
|
||||
);
|
||||
expect(result.shouldForwardOutput).toBe(false);
|
||||
expect(result.newTrigger).toEqual({ reason: 'usage-exhausted' });
|
||||
expect(result.state.streamedTriggerReason).toEqual({
|
||||
expect(result.newTrigger).toMatchObject({ reason: 'usage-exhausted' });
|
||||
expect(result.state.streamedTriggerReason).toMatchObject({
|
||||
reason: 'usage-exhausted',
|
||||
});
|
||||
});
|
||||
@@ -286,7 +289,7 @@ describe('evaluateStreamedOutput', () => {
|
||||
claudeOpts,
|
||||
);
|
||||
expect(result.shouldForwardOutput).toBe(false);
|
||||
expect(result.newTrigger).toEqual({ reason: 'auth-expired' });
|
||||
expect(result.newTrigger).toMatchObject({ reason: 'auth-expired' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -304,8 +307,8 @@ describe('evaluateStreamedOutput', () => {
|
||||
claudeOpts,
|
||||
);
|
||||
expect(result.shouldForwardOutput).toBe(false);
|
||||
expect(result.newTrigger).toEqual({ reason: 'overloaded' });
|
||||
expect(result.state.streamedTriggerReason).toEqual({
|
||||
expect(result.newTrigger).toMatchObject({ reason: 'overloaded' });
|
||||
expect(result.state.streamedTriggerReason).toMatchObject({
|
||||
reason: 'overloaded',
|
||||
});
|
||||
});
|
||||
@@ -323,8 +326,8 @@ describe('evaluateStreamedOutput', () => {
|
||||
claudeOpts,
|
||||
);
|
||||
expect(result.shouldForwardOutput).toBe(false);
|
||||
expect(result.newTrigger).toEqual({ reason: 'org-access-denied' });
|
||||
expect(result.state.streamedTriggerReason).toEqual({
|
||||
expect(result.newTrigger).toMatchObject({ reason: 'org-access-denied' });
|
||||
expect(result.state.streamedTriggerReason).toMatchObject({
|
||||
reason: 'org-access-denied',
|
||||
});
|
||||
});
|
||||
@@ -341,8 +344,8 @@ describe('evaluateStreamedOutput', () => {
|
||||
claudeOpts,
|
||||
);
|
||||
expect(result.shouldForwardOutput).toBe(false);
|
||||
expect(result.newTrigger).toEqual({ reason: 'org-access-denied' });
|
||||
expect(result.state.streamedTriggerReason).toEqual({
|
||||
expect(result.newTrigger).toMatchObject({ reason: 'org-access-denied' });
|
||||
expect(result.state.streamedTriggerReason).toMatchObject({
|
||||
reason: 'org-access-denied',
|
||||
});
|
||||
});
|
||||
@@ -364,7 +367,7 @@ describe('evaluateStreamedOutput', () => {
|
||||
expect(result.shouldForwardOutput).toBe(false);
|
||||
expect(result.newTrigger).toBeUndefined();
|
||||
// Existing trigger preserved
|
||||
expect(result.state.streamedTriggerReason).toEqual({
|
||||
expect(result.state.streamedTriggerReason).toMatchObject({
|
||||
reason: 'usage-exhausted',
|
||||
});
|
||||
});
|
||||
@@ -451,11 +454,11 @@ describe('evaluateStreamedOutput error handling', () => {
|
||||
freshState(),
|
||||
claudeOpts,
|
||||
);
|
||||
expect(result.newTrigger).toEqual({
|
||||
expect(result.newTrigger).toMatchObject({
|
||||
reason: '429',
|
||||
retryAfterMs: 30000,
|
||||
});
|
||||
expect(result.state.streamedTriggerReason).toEqual({
|
||||
expect(result.state.streamedTriggerReason).toMatchObject({
|
||||
reason: '429',
|
||||
retryAfterMs: 30000,
|
||||
});
|
||||
@@ -474,7 +477,7 @@ describe('evaluateStreamedOutput error handling', () => {
|
||||
shortCircuitTriggeredErrors: true,
|
||||
});
|
||||
expect(result.shouldForwardOutput).toBe(false);
|
||||
expect(result.newTrigger).toEqual({ reason: '429' });
|
||||
expect(result.newTrigger).toMatchObject({ reason: '429' });
|
||||
});
|
||||
|
||||
it('skips rotation check when output was already seen', () => {
|
||||
@@ -524,11 +527,11 @@ describe('evaluateStreamedOutput error handling', () => {
|
||||
freshState(),
|
||||
codexOpts,
|
||||
);
|
||||
expect(result.newTrigger).toEqual({
|
||||
expect(result.newTrigger).toMatchObject({
|
||||
reason: '429',
|
||||
message: errorMessage,
|
||||
});
|
||||
expect(result.state.streamedTriggerReason).toEqual({
|
||||
expect(result.state.streamedTriggerReason).toMatchObject({
|
||||
reason: '429',
|
||||
message: errorMessage,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user