Skip to content

Add session name/ID persistence to runtime/pids/#11

Open
craftyc0der wants to merge 3 commits into
masterfrom
claude/session-restart-token-bzDXc
Open

Add session name/ID persistence to runtime/pids/#11
craftyc0der wants to merge 3 commits into
masterfrom
claude/session-restart-token-bzDXc

Conversation

@craftyc0der

Copy link
Copy Markdown
Owner

Each agent now records a {agent_id}.session.json file in
.orchestrator/runtime/pids/ when spawned, capturing:

  • agent_id and cli_command (for resume flag selection)
  • session_name (tmux session name, stable across restarts)
  • session_id (null for now; populated later when extraction is wired up)
  • spawned_at timestamp

AgentState gains session_name and session_id fields (serialized to
state.json). ProjectConfig gains a pids_dir field. Both spawn paths
(standalone and worker-group) write the file.

https://claude.ai/code/session_01BLqWThMChaJesFahQmYVuQ

claude added 2 commits March 28, 2026 20:16
Each agent now records a {agent_id}.session.json file in
.orchestrator/runtime/pids/ when spawned, capturing:
- agent_id and cli_command (for resume flag selection)
- session_name (tmux session name, stable across restarts)
- session_id (null for now; populated later when extraction is wired up)
- spawned_at timestamp

AgentState gains session_name and session_id fields (serialized to
state.json). ProjectConfig gains a pids_dir field. Both spawn paths
(standalone and worker-group) write the file.

https://claude.ai/code/session_01BLqWThMChaJesFahQmYVuQ
Introduces a SessionAdapter trait with per-vendor implementations
(Claude, Gemini, Codex, Copilot, Cursor) that handle the differences
in spawn naming and resume command structure for each CLI tool.

A master OrchestratorSession record (runtime/sessions/<name>.json)
maps a single human-readable name to every agent's vendor session ID,
enabling all agents to be resumed with one flag.

New CLI flags on `orchestrator run`:
  --session <name>  Name this run; saves the session file after startup
  --resume  <name>  Load a saved session; each agent starts with its
                    vendor resume flag (--resume, codex resume, etc.)
                    restoring prior context

How each vendor is handled:
  claude   --name <session_name> on spawn; --resume <name> to restore
  gemini   session ID extracted from ~/.gemini/tmp/*/chats/ (newest)
  codex    session ID from ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl
  copilot  session ID from ~/.copilot/session-state/ (newest dir)
  cursor   UUID extraction deferred (pane-capture step, future work)

https://claude.ai/code/session_01BLqWThMChaJesFahQmYVuQ
- Simplified the logic for checking agent command warnings in `check_agent_command_warnings` by consolidating conditions.
- Updated the `open_terminal_window` function to improve readability.
- Enhanced the handling of session-related commands in the `supervisor` module, introducing a new `command_with_session_mode` function to differentiate between fresh and resumed commands.
- Improved error handling in session loading and saving functions to streamline the process.
- Added new runtime paths for session management in tests to ensure proper directory structure.

This refactor aims to enhance code clarity and maintainability while ensuring robust session management across agents.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants