Skip to content

Commit 75390be

Browse files
authored
Merge pull request #214 from PredicateSystems/state_serialize
serialize state
2 parents 5e52b54 + 0d12322 commit 75390be

5 files changed

Lines changed: 697 additions & 0 deletions

File tree

src/agents/planner-executor/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ export {
6868
type ParsedAction,
6969
type Snapshot,
7070
type SnapshotElement,
71+
type SerializedAgentState,
72+
type SerializedLoopState,
73+
type SerializedRecoveryState,
7174
} from './plan-models';
7275

7376
// Prompts

src/agents/planner-executor/plan-models.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,47 @@ export interface TokenUsageSummary {
262262
byModel: Record<string, TokenUsageTotals>;
263263
}
264264

265+
// ---------------------------------------------------------------------------
266+
// Serialized Agent State (for persistence across sidepanel context loss)
267+
// ---------------------------------------------------------------------------
268+
269+
export interface SerializedLoopState {
270+
stepOutcomes: StepOutcome[];
271+
currentUrl: string;
272+
success: boolean;
273+
error: string | undefined;
274+
fallbackUsed: boolean;
275+
replansUsed: number;
276+
queuedRepairSteps: Array<Record<string, unknown>>;
277+
repairHistory: RepairHistoryEntry[];
278+
}
279+
280+
export interface SerializedRecoveryState {
281+
checkpoints: Array<{
282+
url: string;
283+
stepIndex: number;
284+
snapshotDigest: string;
285+
timestamp: string;
286+
predicatesPassed: string[];
287+
verificationPredicates?: PredicateSpec[];
288+
}>;
289+
recoveryAttemptsUsed: number;
290+
maxRecoveryAttempts: number;
291+
currentRecoveryTarget?: string | null;
292+
maxCheckpoints: number;
293+
}
294+
295+
export interface SerializedAgentState {
296+
runId: string | null;
297+
actionHistory: ActionRecord[];
298+
currentStepIndex: number;
299+
currentStep: { action: string; intent?: string } | null;
300+
currentTaskCategory: string | null;
301+
loopState: SerializedLoopState;
302+
recoveryState: SerializedRecoveryState | null;
303+
tokenUsage: TokenUsageSummary | undefined;
304+
}
305+
265306
// ---------------------------------------------------------------------------
266307
// Snapshot Types
267308
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)