Agent Lifecycle¶
techrevati.runtime.agent_lifecycle ¶
Agent Lifecycle — Agent state machine with event log.
Explicit agent lifecycle states with validated transitions. Every state change is recorded as an event with timestamp and detail. AgentRegistry provides thread-safe concurrent access.
AgentStatus ¶
Bases: str, Enum
Agent lifecycle states with valid transition paths.
InvalidTransitionError ¶
InvalidTransitionError(current, target)
Bases: Exception
Raised when an invalid state transition is attempted.
AgentWorkerEvent
dataclass
¶
AgentWorkerEvent(seq, kind, status, detail, timestamp)
Immutable record of a state transition.
AgentWorker
dataclass
¶
AgentWorker(
worker_id,
role,
phase,
project_id=None,
status=AgentStatus.IDLE,
events=list(),
retry_count=0,
last_error=None,
provider_used=None,
created_at=_now_iso(),
updated_at=_now_iso(),
)
Tracks an agent's lifecycle through execution.
transition ¶
transition(new_status, detail=None)
Validate and execute a state transition. Returns the new event.