JidoGralkor.Lifecycle (jido_gralkor v1.1.2)

Copy Markdown View Source

Jido.AgentServer.Lifecycle implementation that turns AgentServer termination into a Gralkor session-end.

Owns an idle timer (armed from state.lifecycle.idle_timeout when positive), cancels and re-arms on each :touch event the consumer casts on user activity, and on idle expiry returns {:stop, {:shutdown, :idle_timeout}, state}. terminate/2 reads the committed Jido thread id from state.agent.state[:__thread__].id and fire-and-forgets Gralkor.Client.end_session(thread_id) via Task.start; failures are logged but never block termination. First-turn agents (no thread committed yet) terminate without calling Gralkor.

Consumers decide policy (timeout duration, when to call :touch, when to issue GenServer.stop); this module owns the mechanism.