A terminal browser and cross-harness bridge for Codex, Claude Code, and OpenCode
pip install ai-sessions==3.12.0 Copy PIP instructions
The terminal interaction contract is documented in DESIGN.md.
ai-sessions is a searchable terminal browser for local Codex CLI, Claude Code, and OpenCode conversations. It indexes each harness's existing native history. Browsing is read-only; explicit rename and bridge actions use the provider-specific operations described below.
It runs as sessions on Linux and native Windows PowerShell.
Every native session copy has a unique, persistent slug, independent of its display name. Names can repeat; IDs and slugs both work in session commands:
sessions --resume elevate-futures sessions --rename elevate-futures "Elevate futures research" sessions --set-slug elevate-futures futures-research sessions --supervise futures-research sessions --target-log futures-research sessions send futures-research --message "The build passed." The same references work with --hide, --unhide, --compress, --decompress, and messaging --from. Message IDs for reply and receipts stay unchanged. Existing unique display names remain accepted for compatibility; ambiguous names fail without selecting a session.
Slugs are generated once from the session name in lowercase kebab-case. Duplicate names get numeric suffixes. Renaming a session leaves its slug unchanged; --set-slug ID_OR_SLUG NEW_SLUG changes it explicitly. Custom slugs contain 1-64 ASCII letters/digits separated by single hyphens. Retired slugs stay reserved and stop resolving, preventing old commands from targeting a different session.
Find slugs with sessions --list, --json, the browser's selected-session details or i view, and sessions messaging status. Linked copies and forks have separate slugs, including copies in different harness homes. Qualified tool:ID and tool:slug references also work; ambiguous references fail without acting.
Assignments live beside state.json in state.slugs.sqlite3 (following AI_SESSIONS_STATE_FILE when overridden). They survive catalog rebuilds and older launchers saving their state. The registry is updated during loading, never during table rendering or navigation. Messaging resolves only reachable sessions; a slug does not wake an offline session.
Windows Terminal does not expose a stable session-ID-to-tab interface. On Windows, open sessions are identified, but exact tab focusing is intentionally not attempted. Pressing Enter on an open session instead offers to stop the running copy and resume it in the current terminal, so two processes never write to one session.
On Windows sessions stays running underneath the harness it launches. Claude Code now runs in a job tied to that launcher, so if sessions is killed the harness stops with it instead of lingering in the tab and fighting the shell for keystrokes; the conversation is already saved and resumes normally. A harness left in that state by an older version — "detached" — is stopped automatically when sessions next starts, unless it is in the middle of a turn, in which case it is left to finish. Each Windows Terminal tab also remembers the session sessions launched in it, so after an interruption run:
sessions --reattach It resumes whatever that tab lost (stopping a detached copy still sitting in it first), or, in a fresh tab, lists the sessions that lost their terminal to pick from.
Neither Codex nor Claude Code can reload its settings, its login or a new session name while it runs. To pick them up, quit the session and, in the same tab, run:
sessions --reopen It resumes the session that tab last ran, following its conversation if it has since moved to another harness, and reopens a supervisor as a supervisor. In a fresh tab it lists the sessions closed most recently. After a session closes, sessions prints this reminder.
To do both in one step, type this inside the session, in Claude Code or Codex:
! sessions --restart The session closes and sessions reopens it in the same tab, reading its settings, names and login afresh. Run it between turns, as the ! prefix does: it stops the harness at once, so a reply still being written would be cut off. A Codex app-server another window depends on is left running.
To carry the conversation into another harness as it restarts, name that harness:
! sessions --restart --claude ! sessions --restart --codex ! sessions --restart --opencode The session is copied across first, as when you pick another harness in the list, and reopens there in the same tab. If the conversation already has a copy there that is just as far along, that copy is opened instead of making a new one. --launch-tool NAME does the same thing. Naming the harness the session is already in is a plain restart.
The Windows-only windows-curses dependency is installed automatically. psutil is used for portable process inspection.
pipx install ai-sessions On Windows, py -m pip can be used in place of python -m pip.
Run sessions, navigate with the arrow keys or j/k, and press Enter to resume the selected conversation. Tracked cross-harness copies collapse to their logical conversation. Same-title independent threads in one project collapse to a presentation-only container; press Enter, Space, or Right to expand it and then choose the exact thread. No title or directory grouping creates lineage.
sessions --list --tool codex sessions --list --query "is:open dir:my-project" sessions --list --visibility hidden sessions --resume SESSION_ID sessions --resume SESSION_ID --launch-tool claude sessions --resume SESSION_ID --launch-tool codex sessions --resume SESSION_ID --launch-tool opencode sessions --resume SESSION_ID --dry-run sessions --launch-log Each resume records the exact id and command handed to the harness. If a harness ever opens a different conversation than the row you picked, sessions --launch-log shows what was actually requested, which separates a wrong id from a harness resolving the right id to the wrong session.
Updated ages include days, hours, and minutes (for example, 4d 7h 23m); the detail pane retains exact timestamps. Activity counts are transcript messages (t), compactions (c), and user prompts (p). One agent response can generate several transcript messages.
If linked-history validation blocks an exact native row, choose the desired harness with x and press Enter. Recovery asks before using that selected copy as a new tracked starting point. Other copies remain separate; the previous relationship and utility state are backed up. Malformed or actively changing transcripts cannot be recovered this way. Recovery never rewrites native transcript content or silently merges competing histories.
Nothing is deleted by age. Sessions idle for 30 days are compressed instead, and stay in sessions.
A supervisor is a second agent session that watches one of your sessions (the target) and answers your questions about it. It never writes to the target and never sends it messages; you read its answers and decide what to do.
Start or resume one: press S on a session. The first time, you pick the supervisor's harness (the other harness than the target's, unless [supervisor] default_tool is set in config.toml); after that, S resumes the same supervisor. The supervisor opens in the current terminal, like Enter. Keep the target in one terminal tab and sessions in another, and switch between them with Ctrl+Tab on Windows Terminal.
From the command line: sessions --supervise ID [--launch-tool claude|codex] does the same as S.
On a supervisor row: S moves the selection to the target. If the target is open in another tab it says so and does nothing else; it never offers to stop that session. If the target is closed, S resumes it as Enter would.
The details pane names the selected row as MAIN SESSION or SUPERVISOR of ' ', and o still cycles to a view of supervisors alone. The title does not follow later renames of the target, and r renames it freely.
Reset: in i on either row, R then y archives the supervisor and hides its session. The next S starts a fresh one. The old ledger stays on disk.
What the supervisor sees: on your first question it is sent a brief (a digest of the target's conversation, with long pastes shortened, tool calls cleaned to one line each, and the most recent exchanges in full). On each later question it is sent only what the target did since. It can read more with sessions --target-log SUPERVISOR_OR_TARGET_ID [--tail N], which prints the target's cleaned exchanges without moving the supervisor's place.
The ledger: each supervisor keeps a notes file, supervisors/ /ledger.md inside the ai-sessions config folder, next to its other working files. The supervisor edits it, and it is sent again with every brief, so it survives the supervisor's own compaction.
Hooks: supervisors need hooks in Claude Code and Codex. sessions --install-hooks adds them (keeping any hooks you already have) and sessions --uninstall-hooks removes them. Codex asks you to trust a changed hook, so the first Codex session after an install asks once.
Supervisors run with your current launch mode (p). Nothing makes them read-only.
Resuming a session in the harness that recorded it is a read: sessions runs codex resume ID, claude --resume ID, or opencode --session ID against the original ID. Sessions at rest are never rewritten by sessions, and no transcript is ever edited in place.
Only three actions write to provider storage:
Everything else — hiding, sort order, per-session harness preference — stays in this utility's own state.json.
The three harnesses store sessions differently and do not recognise one another's native IDs, so a conversation cannot simply be handed across by reference. Press x (or pass --launch-tool) and ai-sessions bridges it instead: it reads the source transcript, converts the conversation into the target harness's own on-disk format, and writes it there as a new native session. That copy is an ordinary session — the target CLI resumes it, appends to it, and lists it like any other.
sessions --resume CODEX_SESSION_ID --launch-tool claude sessions --resume CLAUDE_SESSION_ID --launch-tool codex sessions --resume OPENCODE_SESSION_ID --launch-tool claude sessions --resume CLAUDE_SESSION_ID --launch-tool opencode The user/assistant conversation crosses over as messages. Tool calls cross over summarised, folded into the turn that made them:
⟦Bash⟧ python -m unittest discover -s tests → Ran 75 tests in 0.066s OK They are deliberately not replayed as live tool calls: a tool_use block would name tools the target harness does not have, and would need a matching result to stay a valid conversation. Summarising keeps what was run and what it returned — usually the part worth having — without inventing structure the target cannot honour. Arguments and output are clipped, Codex's fixed result preamble is stripped, and a Codex exec snippet is reduced to the shell command it actually ran. Reasoning and attachments are dropped entirely.
Because a summary is a record and not a result, the copy opens with a note saying where it came from and warning that the filesystem state is unverified. The source transcript is never modified, and the copy is named (from Codex), (from Claude), or (from OpenCode) so the two are never confused in the list.
A long session is not one conversation but a chain of context windows. When a harness runs out of room it summarises everything so far and carries on from the summary, so the transcript on disk holds every superseded window and a summary of each.
Replaying all of that is both wasteful and untrue to where the session actually stands, so a bridged copy starts at the most recent summary — exactly where the source session itself picks up. On a real 7-compaction session here that is the difference between 949,000 characters with 739 messages silently dropped to fit, and 147,000 characters with nothing dropped at all. Set latest_window = false to replay the whole transcript instead.
OpenCode stores a readable summary, compaction request, and retained-tail boundary in its shared SQLite database. The adapter follows the newest completed summary. A failed-only attempt retains full history, and a successful retry keeps the retained tail after its completed summary; this is a deliberate safety correction to OpenCode 1.18.21's failed-attempt reorder behavior.
Whatever survives the above is fitted to a target-owned token policy. Claude Code and Codex use the 1M-context models configured for this deployment, reserving 5% for target scaffolding: about 950,000 tokens / 1,900,000 projected characters. OpenCode target preparation queries installed models and uses the selected model's effective input limit; when verbose metadata is unavailable it warns and falls back to a 128,000-token compatibility floor. Selection happens at source-message boundaries before same-role messages are assembled for the target. The first message of the selected context and one contiguous newest suffix survive; oversized anchors carry an explicit truncation marker, and the note reports dropped, truncated, source, and assembled counts. These target defaults intentionally replace the previous global 950,000-character ceiling; they are smaller so an unknown target model is less likely to compact immediately on resume.
The bridge refuses before calling the target writer if the selected context would drop messages or truncate an anchor. max_tokens and max_chars choose capacity; they do not authorize omission. The error reports projected source cost, the current budget, loss counts, and the minimum setting needed to fit. Set allow_lossy = true under [bridge] only to deliberately restore the old first-message-plus-newest-suffix behavior; this is dangerous and exact losses remain reported. Starting at the source's latest native compaction summary under latest_window is not budget loss, because that summary replaces earlier windows in the source context.
Set max_tokens in config.toml for an explicit token-denominated ceiling, or tool_calls = false for a conversation-only copy. The deprecated max_chars remains an exact override. Version-1 files automatically written with max_chars = 950000 migrate to the target default; add version = 2 or use max_tokens to make an override explicit.
Every first bridge creates a utility-owned conversation id. The original and each native copy are materializations of that conversation. Equivalent copies share a frontier; byte bookmarks on their transcripts reveal which copy received real work after that frontier. New bookmarks retain ordered fingerprints of conversation records as well as a byte position. Formatting and instruction-metadata rewrites can therefore relocate the position without losing its meaning; edits or missing conversation records still block automatic routing. Timestamps are display data only and never decide which history wins.
Selecting an older row therefore does not resume an older history. ai-sessions follows the conversation head, reuses an equivalent copy in the requested harness when one exists, or creates a new native session from the head. Historical materializations remain available under expansion and in details as superseded. The validated current copy is labeled latest. If two copies advance independently, both are diverged and automatic resume stops instead of silently choosing one branch. Same-title sessions without recorded lineage are independent thread or standalone; their visual grouping never changes launch routing.
The CONNECTION column shows standalone or linked. STATUS separately shows latest, superseded, diverged, or a validation problem. Standalone sessions have no copy status.
The conversation id is stored in state.json and included in new copies as a structured [ai-sessions-provenance v1] marker. State is authoritative today; the marker makes copies auditable and provides a future recovery path, but state reconstruction from transcripts is not implemented yet. Version 5 bridge records migrate conservatively: a possibly edited copy wins over its ancestor so old state cannot silently discard work.
Conversions run through a harness-neutral conversation rather than pairwise. OpenCode is the first production proof: all six ordered cross-harness directions and all three same-harness identities use one core, with no pairwise converter. Support for another CLI costs one adapter rather than a converter per existing harness. The registry requires a name and label, a conservative budget policy, plus operations to read a NativeRef into Turn objects with an opaque checkpoint, write turns as a resumable native session, resolve a native ID, test exact availability, and compare meaningful native state against that checkpoint. The same adapter also owns native discovery, resume arguments, title publication, liveness evidence, native-id patterns, labels, ordering, home-directory semantics, and its launch/budget policy. Bridging and head tracking in both directions then work without pairwise logic.
The registry is dynamic: CLI choices, keyed schema-3 provider profiles, list/browser rendering, discovery, liveness, naming, and conversion all query it at runtime. Unsupported capabilities and unknown harnesses fail explicitly instead of borrowing built-in behavior. An independent fourth-format fixture exercises the whole contract without reusing a built-in adapter. The complete target contract is specified in specs/conversation-log/HARNESS_CONTRACT.md.
A Codex writer has one non-obvious obligation. Codex records the model's context (response_item) separately from what its TUI redraws (user_message and agent_message events), and groups both into turns delimited by task_started/task_complete. A rollout carrying only the first kind resumes with the full conversation in context but a blank screen, which looks exactly like a failed bridge. Writers for other harnesses should expect a similar split and check the resumed session visually, not just by asking the model what it remembers.
One more wrinkle: Codex enumerates its sessions from a local state database rather than from the rollout files, so a copy bridged into Codex is resumable immediately but only appears in the sessions list after Codex itself has opened it once. Copies bridged into Claude Code and OpenCode are listed straight away.
The package defaults to safe. This leaves approval and sandbox behavior to each provider's normal configuration:
claude --resume SESSION_ID codex resume SESSION_ID opencode --session SESSION_ID Dangerous mode adds the providers' explicit bypass flags:
claude --dangerously-skip-permissions --resume SESSION_ID codex --dangerously-bypass-approvals-and-sandbox resume SESSION_ID opencode --auto --session SESSION_ID These options disable important protections. Use them only where you have consciously accepted that risk.
sessions --set-launch-mode safe sessions --set-launch-mode dangerous Use --launch-mode for a one-time override. The active mode is always displayed in the interface header.
The optional custom profile uses structured argument arrays, avoiding shell interpolation:
version = 3 [launch] mode = "custom" claude_command = ["claude"] codex_command = ["codex"] [launch.providers.opencode] command = ["opencode"] bridge_model = "provider/model" # optional; must appear in `opencode models` [launch.custom] claude_args = ["--permission-mode", "acceptEdits"] codex_args = ["--sandbox", "workspace-write", "--ask-for-approval", "on-request"] [terminal] # Opens a terminal on a tmux session whose own terminal died. # {session}, {window}, {pane} and {script} are substituted. # Empty means auto-detect: $TERMINAL, then kitty, wezterm, ghostty, # alacritty, gnome-terminal, konsole, xterm. command = [] [bridge] max_tokens = 150000 allow_lossy = false tool_calls = true latest_window = true By default, a bridge refuses before writing if its selected context would drop or truncate content; increase max_tokens/max_chars to fit it. Set allow_lossy = true only as an explicit, dangerous authorization for those losses; exact dropped and truncated counts are still shown.
Rename/hide state is kept alongside the configuration as state.json. Per-session launch-harness preferences, conversation ids, native members, equivalence frontiers, and opaque native checkpoints are stored there too. A checkpoint on a long transcript keeps its per-record fingerprints in checkpoint-records\ beside state.json, one file per list named by its SHA-256, so the state file stays small; lists nothing has used for a week and no checkpoint names are swept at startup. Unset sessions default to the harness where they were started. Caches use ~/.cache/ai-sessions on Linux and %LOCALAPPDATA%\ai-sessions on Windows. Environment overrides are available through AI_SESSIONS_CONFIG_FILE, AI_SESSIONS_STATE_FILE, AI_SESSIONS_CACHE_DIR, CODEX_HOME, CLAUDE_CONFIG_DIR, and OPENCODE_DB. Prefer the configured OpenCode command's authoritative db path; OPENCODE_DB is the explicit fallback override when that command cannot report one.
A tmux session outlives its terminal. When a window manager restart or a crash takes the terminal window but leaves the tmux server, the pane shells, and the harness process running, the session is still there — sessions just had no way back to it.
Pressing Enter on such a session now opens a terminal attached to it, on the exact window and pane. This happens only when tmux reports no client on the session. A session that already has a client but whose window cannot be raised — different display, Wayland, remote — is not given a second one, because two clients share a session and tmux sizes both to the smaller window; the message explains that instead.
The terminal is resolved from [terminal] command, then $TERMINAL, then the first of kitty, wezterm, ghostty, alacritty, gnome-terminal, konsole, xterm that is installed. With no display at all, nothing is spawned and the message carries the exact tmux attach-session command.
Detection is best-effort and read-only. See What is written, and when for the complete list of operations that touch provider storage.
No transcripts, caches, credentials, local names, or hidden-session state belong in this repository. The defensive .gitignore excludes common provider and local data paths.
python -m unittest discover -s tests -v python -m build CI exercises Python 3.11–3.13 on Ubuntu and Windows.
Run sessions messaging install, then reopen the sessions you want to receive messages (! sesres is shorthand for ! sessions --restart). Find receivers with sessions messaging status and send with sessions send --message "Migration finished". Agents can reply with sessions reply --message "Received".
Codex steering reaches an active turn without canceling its tools; idle threads start a turn. Claude uses its native authenticated inbox and Windows DevSecrets. A successful send reports runtime acceptance or pipe submission, not completion. See the messaging guide for setup, replies, delivery states, home selection, and current Windows/desktop/private-server limits.
Both files in this release have provenance metadata.
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Both files in this release have been uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




