---
name: constant
description: "Carry or consult a conversation between coding agent harnesses (Codex, Claude Code, OpenCode, Antigravity/agy, ACP agents, and plugins; legacy Gemini CLI as a read-only source) with Constant. Use when the user asks to move, hand off, fork, or continue this thread (or another one) in a different agent CLI, ask another runtime about it, find or read back an earlier carried conversation, or mentions Constant by name. Do not use for general session search unrelated to carrying."
allowed-tools: Bash(constant --version), Bash(constant --help), Bash(constant doctor:*), Bash(constant runtimes:*), Bash(constant harnesses:*), Bash(constant sessions:*), Bash(constant ps:*), Bash(constant route:*), Bash(constant recall:*), Bash(constant search:*), Bash(constant record:*), Bash(constant ask:*), Bash(constant rewind:*)
---

# Constant — Portable Agent Cognition

Constant makes agent cognition portable across coding harnesses: it seals one
unedited **Dry Master** record, lets you search/recall verbatim turns, rewind
before bad turns (`rewind`), project past the compaction cliff
(`--render triage`), and re-amp the exact thread across independent harnesses
and models (`carry`, parallel `ask`, `replay`).

Supported native carry targets: `codex`, `claude`, `opencode`.
Supported built-in headless `ask` targets: `codex`, `claude`, `opencode`, `antigravity` (`agy`), plus any configured ACP agent or `constant-adapter-*` plugin.
Antigravity (`agy`) and legacy Gemini CLI sessions can be read, recorded, searched, recalled, and carried from (and Antigravity can be consulted directly via `constant ask --to antigravity`, returning a resumable `agy -r <id>`).

## Learn the installed CLI

The installed binary is the authority for syntax. Check it first:

```bash
constant --version
constant doctor --json      # installed runtimes, versions, and whether each is validated
```

`constant --help` prints the full command reference. `constant integration`
shows which runtimes have this guide installed as a skill.

Use `--json` (or `--plain`) on every read command. Several commands open an
interactive picker or explorer when they run in a terminal with no arguments
(`constant resume`, `constant sessions`, `constant trail`). Never run
`constant host` or `constant resume` from an agent: they take over the
terminal with a live runtime.

## Carry this conversation to another runtime

Name your own session explicitly instead of relying on "newest in this
folder":

| You are running in | Your session id |
| --- | --- |
| Claude Code | `$CLAUDE_CODE_SESSION_ID` |
| Codex | `$CODEX_THREAD_ID` |
| Antigravity (`agy`) | `$ANTIGRAVITY_CONVERSATION_ID` |
| other | `constant sessions --from <runtime> --json`, newest `id` for this `cwd` |

Preview, then carry:

```bash
constant carry --session "$CLAUDE_CODE_SESSION_ID" --to codex --dry-run --json
constant carry --session "$CLAUDE_CODE_SESSION_ID" --to codex --json
```

The JSON result includes:

- `id`: the target runtime's session id
- `resume`: the exact command that resumes it (for example `codex resume <id>`)
- `handle`: the conversation's stable name, such as `cobalt-37`
- `receipt`: what was kept, dropped, and redacted (`turns`, `tools`,
  `dropped_tools`, `dropped_scaffold`, `dropped_reasoning`, `redactions`)

Give the user the `resume` command and the receipt. Carrying does not move
the user's terminal; the user, or a terminal multiplexer they asked you to
drive, runs the `resume` command.

Your current turn is still being written while you run the carry, so the
carried copy ends at the last completed turn. Say so if it matters.

Options:

- `--with-tools`: also carry tool calls and their results (redacted and size
  capped). Without it, only the conversation text carries.
- `--new`: fork a separate continuation instead of refreshing the existing
  target session for this conversation.
- `--render paged`: for very long threads, carry a compact layout (summary
  card, index, recent turns verbatim). Older turns stay readable with
  `constant recall`.
- `--render triage`: anti-compaction layout for bloated threads — pins Turn 1
  and constraint/decision user turns verbatim, rescues earlier failing tool
  outputs, collapses bulky passing tool outputs (`> 400` chars) into exact
  `constant recall` pointers, and keeps the recent tail + recent failures
  verbatim (the full Dry Master stays untouched).
- `--until-turn K`: rewind/truncate the projection after 1-based Turn K (always
  mints a fresh fork; never thins the sealed Dry Master). Or use the dedicated
  `constant rewind <HANDLE> --turn K [--to <RT>] [--question ...]` command.

Carrying again to the same target refreshes that target session in place.
The source session is never modified.

## Ask another runtime (single or parallel multi-mind)

When the user wants a second runtime's judgment — or wants to compare multiple
independent runtimes on the exact same unedited conversation — consult them
headlessly:

| You are running in | Your session id |
| --- | --- |
| Claude Code | `$CLAUDE_CODE_SESSION_ID` |
| Codex | `$CODEX_THREAD_ID` |
| Antigravity (`agy`) | `$ANTIGRAVITY_CONVERSATION_ID` |

```bash
# Single runtime consultation (including Antigravity via `agy`)
constant ask --to antigravity --session "$CLAUDE_CODE_SESSION_ID" \
  --question "Review the current plan for hidden failure modes." --json

# Parallel multi-mind / harness:model matrix with worktree isolation + objective verification
constant ask --to claude:sonnet,claude:opus,codex:o3,antigravity \
  --session "$CLAUDE_CODE_SESSION_ID" \
  --with-tools --render triage --isolate worktree \
  --verify-cmd "cargo test" \
  --question "Audit this root cause and propose a minimal patch." --json

# Rewind a conversation back to Turn 6 (before a bad turn/hallucination) and fork fresh
constant rewind cobalt-37 --turn 6 --to claude --render triage --with-tools --json

# Long question via stdin
constant ask --to codex --session "$CLAUDE_CODE_SESSION_ID" \
  --question - < question.txt --json
```

`ask` seals ONE frozen Dry Master snapshot of the conversation, forks built-in
targets (`codex`, `claude`, `opencode`) into fresh native projections (or feeds
the Dry Master directly to `antigravity`, configured ACP agents, and
`constant-adapter-*` plugins), runs them non-interactively, and returns
structured JSON. It never takes over the terminal, never modifies the source
conversation, and never overwrites an existing paired projection.

- **Multi-target & `harness:model` (`--to a:m1,a:m2,b:m3` or repeated `--to`)**:
  fans out concurrently across all cells from the same frozen Dry Master chapter
  and emits `results[]` plus a deterministic zero-LLM `divergence` summary
  (`shared_references`, `unique_references_by_target`, `files_touched_by_target`,
  `patches_differ`, `verify_passed_by`, `verify_failed_by`, `verify_differs`).
- **Objective verification (`--verify-cmd CMD`, `--verify-timeout SECS`)**:
  executes `CMD` inside each target's workspace/ephemeral worktree right after
  the runtime finishes (before worktree cleanup) and records exact pass/fail,
  exit code, and stdout/stderr tails per target.
- **Anti-compaction & Rewind (`--render triage`, `--until-turn K`)**: works on
  `carry`, `ask`, `replay`, `rewind`, and MCP (`constant_carry`, `constant_ask`).
- **Isolation (`--isolate auto|worktree|readonly|none`)**:
  - `auto` (default): `worktree` for multi-target runs inside a git repo, `none`
    for single target.
  - `worktree`: ephemeral detached git worktree per target (mirrors uncommitted
    tracked changes, captures each runtime's `files_touched` and `patch_diff`,
    and deletes the worktree unconditionally on exit).
  - `readonly`: passes verified read-only sandbox flags (`codex exec -s read-only`,
    `claude --permission-mode plan`, plugin `readonly: true`; ACP cancels
    permission prompts automatically).
- **Capabilities**: run `constant runtimes --json` to see built-ins, configured
  ACP agents (`~/.constant/runtimes.json`), and external plugins.
- **Native MCP server**: if this host has Constant registered via `constant mcp`
  (see `constant integration mcp-config`), prefer calling the MCP tools directly
  (`constant_ask`, `constant_record`, `constant_search`, `constant_recall`,
  `constant_carry`, `constant_sessions`, `constant_runtimes`).

Treat an ask as billable provider work: use it only when the user asks or
authorizes it.

## Find conversations

```bash
constant sessions --json               # carryable sessions for this folder, newest first
constant sessions --all --json         # every runtime store
constant sessions auth --json          # filter by name or id
constant ps --json                     # agent sessions running right now, with resume commands
constant route --json                  # carry lineage (which session came from which)
```

## Record, search, and read history back

Every carry and `constant record` seals a **Dry Master** snapshot containing
all redacted turns and tool calls/outputs, its receipt, a source SHA-256
fingerprint, and the source runtime's model/git metadata:

```bash
constant record --session "$CLAUDE_CODE_SESSION_ID" --json   # seal dry master (idempotent by sha256)
constant search cobalt-37 "norway yaml" --json               # search turns for exact recall addresses
constant search cobalt-37 "ECONNRESET" --tools --json        # also search redacted tool calls/outputs
constant recall cobalt-37                                    # filed turns, by handle
constant recall cobalt-37 ch04 12                            # one turn, verbatim
constant recall cobalt-37 ch04 3-9 --tools --json            # range + attached redacted tool traffic
constant export --session <id> --out thread.json             # distilled, redacted conversation as JSON
```

`search`, `recall`, and `export` are read-only. `record` writes only to
`~/.constant/` and never modifies any runtime's session store.

## Rules

- Carry only when the user asks for it. A carry writes a new session into
  the target runtime's store (`~/.codex`, `~/.claude`, or OpenCode through
  its own import command).
- Ask only when the user asks or authorizes it. An ask carries the thread and
  invokes the target runtime, which may consume paid provider usage.
- Do not delete sessions, snapshots, or `~/.constant`. Constant never
  overwrites an original session; keep it that way.
- Never run the `gemini` binary to inspect sessions. Carry gemini sessions
  with `constant carry --session <path> --to <target>` instead.
- Redaction covers common secrets (API keys, tokens, private keys, auth
  headers, email addresses), not everything. Do not carry a thread into a
  runtime the user would not want reading it.
- If `doctor` shows a runtime version that is not validated, tell the user
  before carrying into it.
