refactor(team): move opencode retry policy helper
This commit is contained in:
parent
9fe9f81046
commit
afe50439b1
3 changed files with 20 additions and 15 deletions
|
|
@ -133,6 +133,7 @@ import {
|
||||||
} from './opencode/delivery/OpenCodePromptDeliveryLedger';
|
} from './opencode/delivery/OpenCodePromptDeliveryLedger';
|
||||||
import {
|
import {
|
||||||
isOpenCodePromptDeliveryObserveLaterResponseState,
|
isOpenCodePromptDeliveryObserveLaterResponseState,
|
||||||
|
isOpenCodePromptDeliveryRetryAttemptDue,
|
||||||
isOpenCodePromptDeliveryRetryableResponseState,
|
isOpenCodePromptDeliveryRetryableResponseState,
|
||||||
isOpenCodeVisibleReplySemanticallySufficient,
|
isOpenCodeVisibleReplySemanticallySufficient,
|
||||||
isOpenCodeVisibleReplyReadCommitAllowed,
|
isOpenCodeVisibleReplyReadCommitAllowed,
|
||||||
|
|
@ -1504,20 +1505,6 @@ function nowIso(): string {
|
||||||
return new Date().toISOString();
|
return new Date().toISOString();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isOpenCodePromptDeliveryRetryAttemptDue(input: {
|
|
||||||
attemptDue: boolean;
|
|
||||||
ledgerRecord: Pick<OpenCodePromptDeliveryLedgerRecord, 'status' | 'responseState'>;
|
|
||||||
}): boolean {
|
|
||||||
if (!input.attemptDue) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
input.ledgerRecord.status === 'retry_scheduled' ||
|
|
||||||
input.ledgerRecord.status === 'failed_retryable' ||
|
|
||||||
isOpenCodePromptDeliveryRetryableResponseState(input.ledgerRecord.responseState)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function createInitialMemberSpawnStatusEntry(): MemberSpawnStatusEntry {
|
function createInitialMemberSpawnStatusEntry(): MemberSpawnStatusEntry {
|
||||||
const updatedAt = nowIso();
|
const updatedAt = nowIso();
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import type { AgentActionMode, InboxMessage, TaskRef } from '@shared/types/team';
|
import type { AgentActionMode, InboxMessage, TaskRef } from '@shared/types/team';
|
||||||
import type { OpenCodeDeliveryResponseState } from '../bridge/OpenCodeBridgeCommandContract';
|
import type { OpenCodeDeliveryResponseState } from '../bridge/OpenCodeBridgeCommandContract';
|
||||||
|
import type { OpenCodePromptDeliveryStatus } from './OpenCodePromptDeliveryLedger';
|
||||||
|
|
||||||
export const OPENCODE_PROMPT_DELIVERY_OBSERVE_DELAY_MS = 3_000;
|
export const OPENCODE_PROMPT_DELIVERY_OBSERVE_DELAY_MS = 3_000;
|
||||||
export const OPENCODE_PROMPT_DELIVERY_RETRY_DELAY_MS = 15_000;
|
export const OPENCODE_PROMPT_DELIVERY_RETRY_DELAY_MS = 15_000;
|
||||||
|
|
@ -96,6 +97,23 @@ export function isOpenCodePromptDeliveryRetryableResponseState(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isOpenCodePromptDeliveryRetryAttemptDue(input: {
|
||||||
|
attemptDue: boolean;
|
||||||
|
ledgerRecord: {
|
||||||
|
status: OpenCodePromptDeliveryStatus;
|
||||||
|
responseState: OpenCodeDeliveryResponseState;
|
||||||
|
};
|
||||||
|
}): boolean {
|
||||||
|
if (!input.attemptDue) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
input.ledgerRecord.status === 'retry_scheduled' ||
|
||||||
|
input.ledgerRecord.status === 'failed_retryable' ||
|
||||||
|
isOpenCodePromptDeliveryRetryableResponseState(input.ledgerRecord.responseState)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function isOpenCodePromptDeliveryObserveLaterResponseState(
|
export function isOpenCodePromptDeliveryObserveLaterResponseState(
|
||||||
state: OpenCodeDeliveryResponseState | undefined
|
state: OpenCodeDeliveryResponseState | undefined
|
||||||
): boolean {
|
): boolean {
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ import { describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
isOpenCodePromptDeliveryObserveLaterResponseState,
|
isOpenCodePromptDeliveryObserveLaterResponseState,
|
||||||
|
isOpenCodePromptDeliveryRetryAttemptDue,
|
||||||
isOpenCodePromptDeliveryRetryableResponseState,
|
isOpenCodePromptDeliveryRetryableResponseState,
|
||||||
} from '@main/services/team/opencode/delivery/OpenCodePromptDeliveryWatchdog';
|
} from '@main/services/team/opencode/delivery/OpenCodePromptDeliveryWatchdog';
|
||||||
import { isOpenCodePromptDeliveryRetryAttemptDue } from '@main/services/team/TeamProvisioningService';
|
|
||||||
|
|
||||||
describe('OpenCodePromptDeliveryWatchdog retry policy', () => {
|
describe('OpenCodePromptDeliveryWatchdog retry policy', () => {
|
||||||
it('treats stale OpenCode sessions as retryable after observation', () => {
|
it('treats stale OpenCode sessions as retryable after observation', () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue