Overview
TheSession interface represents a running agent session in the orchestrator. Each session encapsulates an AI coding agent working on a specific task, tracking its lifecycle state, activity, workspace, and associated resources.
Interface Definition
Properties
Unique session identifier (e.g.
"my-app-3", "backend-12"). Used for all session operations.Which project this session belongs to. References a project ID from the orchestrator config.
Current lifecycle status of the session. One of:
"spawning"- Session is being created"working"- Agent is actively working"pr_open"- PR has been created"ci_failed"- CI checks failed"review_pending"- Awaiting code review"changes_requested"- Reviewer requested changes"approved"- PR approved"mergeable"- Ready to merge"merged"- PR merged (terminal state)"cleanup"- Cleaning up resources (terminal state)"needs_input"- Waiting for human input"stuck"- Agent is stuck/blocked"errored"- Session encountered an error (terminal state)"killed"- Session was manually killed (terminal state)"done"- Session completed successfully (terminal state)"terminated"- Session terminated (terminal state)
Activity state from agent plugin (null = not yet determined). One of:
"active"- Agent is processing (thinking, writing code)"ready"- Agent finished its turn, alive and waiting for input"idle"- Agent has been inactive for a while (stale)"waiting_input"- Agent is asking a question / permission prompt"blocked"- Agent hit an error or is stuck"exited"- Agent process is no longer running (terminal state)
Git branch name for this session. Null if branch not yet created.
Issue identifier if working on a specific issue (e.g. GitHub issue number, Linear issue ID). Null if not issue-based.
Pull request information once PR is created. Null if PR not yet opened.
Absolute path to the workspace directory on disk. Null if workspace not yet created.
Runtime handle for communicating with the session environment (tmux, docker, etc.). Null if runtime not yet initialized.
Agent session metadata (summary, cost estimates, internal session ID). Null if not yet available.
Timestamp when the session was created.
Timestamp of last detected activity. Updated by lifecycle manager during activity checks.
When this session was last restored from a terminal state. Undefined if never restored.
Key-value pairs for arbitrary metadata. Used for custom tags, labels, or plugin-specific data.
Related Types
SessionId
"my-app-1", "backend-12").
SessionStatus
ActivityState
SessionSpawnConfig
SessionManager.spawn().
Usage Examples
Creating a Session
Checking Session State
Monitoring Activity
Implementation Notes
Terminal States
Sessions in terminal states (defined byTERMINAL_STATUSES and TERMINAL_ACTIVITIES) have finished executing and their resources can be cleaned up:
Restorable Sessions
Some terminal sessions can be restored (e.g. errored, killed) while others cannot (e.g. merged):Activity Detection
Theactivity field is populated by the agent plugin’s getActivityState() method, which uses agent-native mechanisms (JSONL logs, SQLite, etc.) rather than terminal output parsing.
