UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

11 lines (10 loc) • 421 B
import { SessionError } from "../harness/types.js"; export class ParentChainGuard { stepped = new Set(); stepOnto(id) { if (this.stepped.has(id)) { throw new SessionError("corrupt_session", `Entry ${id} is its own ancestor (parent chain cycles at ${id}) — start a new session, or fork from an entry above the loop`, undefined, "parent_loop"); } this.stepped.add(id); } }