The a4sx CLI (formerly amdx)

v0.3 (additive over v0.2, CLI 0.37.0): Claude Code's own sign-in in a launch profile (local_login) and the built-in default profile «default»; nothing from v0.2 changes.

v0.2 (additive over v0.1): the command is now a4sx. amdx keeps working as an alias for the same file, and everything v0.1 documents (flags, env vars, config dir, /cli/amdx.py) still works. What changed and how the old names map is in Renamed from amdx at the end.

The a4sx CLI lets you save your harness sessions to your private library and resume them on any machine — and configure the fleet-router for a workspace you own. It's a single stdlib-Python script; no dependencies beyond Python 3 and curl. (It replaces the former library / agent-mdx-launcher.sh / push_session.py scripts, now removed.)

Your saved sessions live in a personal library (one private store per account, provisioned on first use — never published, never a URL). Workspace-scoped commands (router-*) act on a workspace you own or admin. (The API and the --tenant flag still say tenant; it is the same thing.)

Install

One line — installs a4sx (plus the amdx alias) into ~/.local/bin and adds it to your PATH:

curl -fsSL https://session-exchange.com/install.sh | sh

The installer prints the version, and warns if a different a4sx earlier on your PATH would shadow it. Update anytime by re-running the one-liner, or a4sx update. Check versions with a4sx --version.

Windows (native, a4sx ≥ 0.14.0). In PowerShell (5.1 or 7), with Python 3.10 or newer installed:

irm https://session-exchange.com/install.ps1 | iex

It puts a4sx.cmd and amdx.cmd into %LOCALAPPDATA%\Programs\a4sx, adds that dir to your user PATH (the current window too), and replaces a file only after it matched the sha256 the server sent with it. Your sign-in and config stay in %USERPROFILE%\.config\a4sx, the session state in %LOCALAPPDATA%\a4sx; the files that hold a sign-in or a key are restricted to your user (and SYSTEM) by their ACL, the Windows counterpart of mode 600. WSL2 works as well: inside WSL, use the Linux one-liner above.

Prefer no install? You can drive the same flow with plain curl + a device login — see Upload without installing at the end. (In the app: My Sessions → Upload a session → "no install (agent)".)

Sign in (once)

a4sx login                 # opens a browser approval (Tailscale-style); stores the session
a4sx login --provider google   # pin the OAuth provider (google | github)
a4sx login --token ge_sess_…   # persist a session you already have, no browser
a4sx login --base localhost:18080   # sign in to another server (e.g. a local collector)

a4sx login signs in to --base, else $A4SX_BASE, else session-exchange.com, and prints signing in to <url> first so you can see which server it is.

No browser on this machine (SSH, a server, a container)? (a4sx ≥ 0.8.10) a4sx login notices — an SSH session, no DISPLAY/WAYLAND_DISPLAY on Linux, only a text-mode browser, or a failed open — says so, and prints a short link to open on any other device (your phone):

No browser can be opened from here (this is an SSH session).
Sign in from any device — your phone or another computer:

  https://session-exchange.com/auth/cli/d/ABCD-EFGH

  (or open https://session-exchange.com/auth/cli/device and type the code below)

With qrencode installed it also draws the link as a QR code (nothing is bundled; without it you get the link alone). Force this mode with a4sx login --no-browser or A4SX_NO_BROWSER=1. If you already hold a session token, skip the browser entirely: a4sx login --token ge_sess_… (or export A4SX_SESSION=… for one shell).

A sign-in link expires after 10 minutes. A running a4sx login restarts it in place: it prints a fresh code, and a link you already opened (the chooser, the short link, even a provider sign-in in progress) continues on the new sign-in — no need to run the command again. It gives up after five restarts (about an hour). A deploy (503) or a rate limit (429) on the start call is retried after the server's Retry-After.

The session is stored at ~/.config/a4sx/session (chmod 600). For a one-shot shell instead of storing it: export A4SX_SESSION=ge_sess_….

Save, list & manage sessions

a4sx push <session>.jsonl --label my-work    # push a transcript to your library
a4sx push --latest --label my-work           # auto-pick the most-recently-modified local session
a4sx push <session>.jsonl --into <cid>       # push as a NEW VERSION of an existing saved session
a4sx list                                    # your saved sessions, rendered as a lineage tree
a4sx list --sort created                     # order: updated (default) | created | name
a4sx delete my-work                          # remove a saved session from your library
a4sx craft base-a base-b --label combined    # compile ONE resumable base from several sources
a4sx tokens my-work                          # token footprint vs a model window (when to squash)
a4sx squash my-work                          # recipe to compact it into a fresh, resumable tip

A transcript for a Claude Code session is the newest file under ~/.claude/projects/*/*.jsonl (or $CLAUDE_CONFIG_DIR/projects/… when that is set — a4sx honours it). The project folder name is the working directory with every non-alphanumeric character replaced by -. a4sx talks https to any server; plain http is used only for a loopback host (localhost, 127.0.0.1, ::1), e.g. a local test collector via A4SX_BASE=http://localhost:18080.

⚠ Scrub first. A transcript contains everything that was in context — possibly credentials, tokens, private paths, internal hostnames. a4sx push scrubs them on your machine, before the upload, with the server's rules, and the server scrubs every upload again on arrival. Review with --dry-run first; the opt-outs below are for special cases only.

What push changes before upload (a4sx ≥ 0.10.15)

By default a4sx push runs the client-side scrub before the upload, so the bytes stored in your library can differ from your local file. Since 0.10.15 it applies the same rules as the server:

  • secrets: bearer/Authorization values, vendor tokens (sk-ant-…, ghp_…, AWS key ids, …), URL credentials, PEM private keys, secret-named keys and assignments, short passwords;
  • command-line passwords: --password X / --password=X (and --db-password, --pass, --pwd), curl -u user:X / --user user:X (the user is kept; a numeric uid:gid is not a password), db_pass=X / DB_PASS=X, pwd=X (only with a non-path value: pwd=/home/x is a directory), mysql -pX / mysqldump -p'X'. Placeholders such as $DB_PASS or <your password> are kept;
  • Google Sheet/Drive ids;
  • personal data, hosts, IPs and paths: e-mail addresses, the user name in home-directory paths (/home/[REDACTED-USER]/…), IPv4/IPv6/MAC addresses, subdomains of the product's own domains (the public session-exchange.com itself stays nameable), private-key file paths.

Rules that name private infrastructure (host names, key-file names, device ids) are server-only and not part of the public CLI; the server still applies them on upload. push always tells you, on stderr, before it uploads:

a4sx push: client scrub: 2 lines changed (bearer: 2, email: 1) — lines 14, 27
a4sx push: local sha256    1b08…
a4sx push: uploaded sha256 3526… — DIFFERS from the local file (the client scrub rewrote it). …
a4sx push: server scrub: 0 redactions (counted on the uploaded bytes; the 2 client-side line change(s) above are NOT included)

The server's redactions count covers only what the server changed in the already client-scrubbed upload; the client count is reported separately (stderr, and as client_scrub — {enabled, mode, lines_changed, rules, lines, local_sha256, uploaded_sha256, identical} — in the JSON on stdout). Only rule names and line numbers are printed, never the matched values.

FlagEffect
--dry-runprint each line the client scrub would change (line N col C: <rule> [masked K chars]) and the sha256 that would be uploaded; uploads nothing and needs no login
--fail-on-scrubexit 3 without uploading if the client scrub would change anything (for gated pipelines that scrub beforehand); combine with --dry-run for a pure check. Not combinable with --no-scrub
--keep-piispecial cases only. Keep personal data, host names, IP/MAC addresses, home-directory user names and key-file paths; secrets, command-line passwords and Sheet ids are still removed. Prints a warning
--no-scrubspecial cases only (e.g. a backup you reviewed yourself). Skip the whole client scrub; the local bytes are uploaded as-is. Prints a warning. The server still scrubs on upload, so the stored copy is not a raw backup. Not combinable with --keep-pii

Every push sends the mode it used with the upload, client_scrub=full|secrets-only|none (the mode field above): full by default, secrets-only with --keep-pii, none with --no-scrub. The server receives it but does not store it or act on it yet: it scrubs every upload regardless. The opt-outs are per-run flags: no config key or environment variable turns them on, and each run that uses one prints a warning to stderr naming what is skipped.

If a line is flagged on purpose (e.g. a lesson's deliberately fake Bearer not-a-real-token), review it with --dry-run and push with --no-scrub if you want those exact bytes sent.

Resume anywhere

a4sx launch                          # new blank session in the current dir
a4sx launch --a4sx-session my-work   # start a NEW local session seeded from a saved base
a4sx launch --a4sx-session      # pick a base interactively
a4sx fetch my-work                   # just fetch a saved session's contents (no launch)

To resume a saved session, always pass --a4sx-session <name>. A bare positional (a4sx launch my-work) goes to the harness as the first prompt of a new blank session; when it looks like a saved label, a4sx prints a warning with the right command.

--a4sx-session <base> writes the base's transcript to a fresh local session id and resumes into it — that new session is your working session, seeded with the base. You work in it directly; the saved server copy is never touched (it lives in your library).

Lineage — the library is a tree

When you launch --a4sx-session <base> and later push that session fresh (no --into), a4sx records a parent edge back to the base. a4sx list then renders your library as a tree, with each spin-off nested under the session it was seeded from:

 #  name                            created           updated           vers     ctx  title
 1  session-ceea288e-backup         2026-09-20 10:00  2026-09-29 21:50     4    182k  Session ceea288e — incremental backup
 2  └─ spin-off                     2026-09-27 08:00  2026-09-27 08:00     1     40k  a spin-off seeded from the backup
 3  fleet-router-base               2026-09-12 16:30  2026-09-18 11:05     2     95k  fleet-router-base

Columns (a4sx ≥ 0.9.0): created = first upload, updated = last push, both compact YYYY-MM-DD HH:MM in your local time zone; vers = how many backup versions the entry has (specs/session-library §2.2). --sort updated (default, last push first) | created (newest first) | name (A→Z); rows with no times (an older server) sort last and print -. The tree keeps the chosen order among siblings, so a spin-off stays under its base.

  • The edge is captured at launch (a sidecar keyed by the new session id) and stamped on the first fresh push. It's validated server-side by exact collection id against your own library — a parent that isn't yours, doesn't exist, or would point at itself is dropped (no bogus edges).
  • --into <cid> versions the same saved session (e.g. an incremental backup) and carries the parent forward, so a derived session keeps its lineage across every backup.
  • The same tree shows in the web app under My Sessions, with a "forked from … on <date>" note on each child.

Token footprint — how big is a session

A resumable base grows every time you work in it, and eventually it won't fit a model's context window. a4sx tokens reads a transcript's per-turn usage records and tells you where it stands:

a4sx tokens my-work                  # a saved session (by name/label/id)
a4sx tokens --latest                 # the most recent local session
a4sx tokens ./transcript.jsonl --window 1000000   # a local file, against a 1M window
session: my-work (col-lib-…)
  current context :   255,252  (128% of 200k)     # what a resume would cost right now
  peak context    :   999,572  (500% of 200k)     # the largest any single turn reached
  total output    :   792,892   over 240 turns
  ⚠ near/over the 200k window — consider a squash + compress …

current ≈ input + cache_read + cache_creation of the last turn (what resuming pays); peak is the max any turn reached. Pass --window for the model you'll resume on (models differ; default 200k). A base with no usage records (old or crafted) reports a rough ≈chars/4 estimate.

Session size (context window)

How big a session gets is your call — models have different context windows (200k, 1M, …), and a4sx is agnostic to it: a4sx launch always resumes exactly what you ask and never refuses or silently switches on size. It just gives you the signals and the tools to manage it however you like.

  • Signals (the real per-turn context occupancy — input + cache — not the transcript's file size): a4sx tokens <name> [--window N] shows current/peak (and % of a window you choose); a4sx list shows a ctx column; My Sessions shows a per-session context chip; a4sx launch prints the base's context size as it resumes (informational only).

Squash into a compact tip (optional)

If you want a smaller resume point, compact a session into a compact tip — a small version you resume from, while the full append-only history stays for provenance. Compression is a model step (the server has no LLM). a4sx squash <name> prints the recipe with the ids filled in:

  1. Measure (optional) — a4sx tokens <name> --window <your-window>.
  2. Merge first only if the lineage branched — a linear chain's leaf already contains the whole history; for a branchy tree, a4sx craft leaf-a leaf-b --label merged unions the leaves.
  3. Compress — a4sx launch --a4sx-session <name>, and in that session have the model write a compact hand-off (durable state, open threads, decisions — dropping resolved back-and-forth), or run Claude Code's /compact.
  4. Save it as the compact tip — a4sx push <compacted>.jsonl --into <name> --compact. --into keeps it as a new version of the same session; --compact marks it the resume tip.
  5. Use it — a4sx launch --a4sx-session <name> --from-compact resumes the compact tip; plain a4sx launch still resumes the full latest. Your choice, every time.

a4sx squash <name> does the mechanical parts (resolve, show size, cache the leaf, print the exact commands); the semantic compaction happens in your harness.

--from-compact also honors your harness's own compaction — no squash needed. If you ran Claude Code's /compact in a session (or it auto-compacted), that summary is already in the transcript as a compact_boundary. a4sx launch --a4sx-session <name> --from-compact will resume from that last boundary (summary + everything after) — a small, clean resume — while the server keeps the full append-only history in its version chain, untouched. So a continuously-backed-up session stays whole on the server, and you can always resume it light. --from-compact prefers an explicitly-pushed compact tip if one exists, else falls back to the harness boundary.

Build on a session you bought (Add to library)

A session you buy or import from the marketplace lives in the seller's workspace — it's not in your library, so it can't be launched as a base directly. Acquiring pulls a private copy into your library that remembers where it came from, and from there it behaves like any saved session:

a4sx acquire <marketplace-cid>              # add an ENTITLED collection to your library as a private base copy
a4sx launch --a4sx-session <marketplace-cid>   # same thing implicitly — auto-acquires, then launches
  • In the web app this is the Add to library button (for a session collection it imports and makes the launchable copy in one step). a4sx acquire is the same action.
  • Acquiring is gated: you must be entitled (bought it, or it's free/public). A paid collection you don't own returns 402 — buy it in the web app first.
  • The copy is staged private in your library (col-lib-*), tagged acquired_from = {cid, tenant, version}. a4sx list and My Sessions mark it "added from the marketplace …". Re-acquiring the same source just adds a new version — one library entry.
  • Continue it normally: a4sx launch --a4sx-session <it> → work → a4sx push → your derivatives nest under the acquired copy (library parent), exactly like any other base.
  • Publishing a derivative is different. The private acquired_from is provenance only — no royalties. If you publish a derivative to a seller workspace (/library/session/{cid}/publish-to/{tenant}), the response carries a builds_on_hint; declare cross-author lineage explicitly (POST /marketplace/collections/{new_cid}/lineage) so credit/royalties are recorded. That edge is author-gated and yours to make — the bridge never declares it for you.

Workspaces & the fleet-router

Not generally available yet. The fleet-router is not yet available on the hosted service: POST /library/router-token/<tenant> answers 503 router_not_yet_available and the router-dependent Data-Flywheel cannot be purchased. You can already pre-stage your BYO upstream with POST /library/router-config/<tenant>. The contract below describes the router once it is available.

If your account can act in more than one workspace, list them and pass the id explicitly:

a4sx workspaces                        # id · plan · role · trial state (alias: a4sx tenants)
a4sx router-token --workspace <id>     # mint the router API key (emitter token) for that workspace
a4sx router-config --workspace <id> --route openrouter --key <provider-key>

--workspace and --tenant are the same flag (on acquire, router-token, router-config).

The fleet-router is an Anthropic-compatible Messages endpoint. router-config publishes YOUR provider credential (BYO) into your workspace's vault so the router can serve you — your own account is used; a4sx never lends one. Then point a harness at the router with the token from router-token as the API key (ANTHROPIC_BASE_URL=<router base_url>). Requires the router addon on the workspace.

Launch profiles

A launch profile is how a harness resumes your sessions — model, reasoning proxy, headers, flags (never your API key). a4sx launch uses your default, or --profile <id>.

a4sx profiles                          # list your profiles
a4sx profile --set model=… --set base_url=… --header X-Example=value
a4sx profile --set-default <id>
a4sx profile --effective               # show the profile merged with client defaults

Claude Code's own sign-in in a profile (local_login). Most people run Claude Code on their own sign-in. a4sx profile --set local_login=true (with --name <id> for another profile) makes every start with that profile do what a4sx launch --local-login does: no router, no base_url, no a4sx key. local_login is kept on this host only (launch-profiles.json next to the local config), never on the server, so no server profile can switch a host onto or off your Claude login. --set local_login=false stops the fallback to that sign-in (where nothing else is set up the start is then refused and says why), and --set local_login= removes the setting. A launch-profiles.json this a4sx can't use (broken, or written by a newer a4sx) is ignored, with one line that says how to fix it; a4sx never overwrites it.

With nothing set up (no a4sx sign-in on this host), a4sx uses a built-in default profile «default» with local_login=true: a4sx launch starts Claude Code on its own sign-in (signed in without a launch profile, the first-run setup runs as before). a4sx profiles lists it as built-in. It is never written anywhere, and it never outranks a profile of yours, a provider of your own in the shell (ANTHROPIC_API_KEY and the like), a router, a base_url or a profile the server assigned a cell.

Which one applies, highest first (a4sx launch --explain shows the value and its source):

Source
1a4sx launch --local-login (this start)
2the cell's setting, a4sx mesh cell local-login <cell> on|off
3the local profile: --profile <id>'s, else your default profile's (the server's default when you're signed in, else «default»; mesh and cell starts: «default») local_login
4the built-in default profile (only where nothing else is set up)

local_login=true next to a router or base_url is refused: in the same profile --set, against the server profile of that name, with --upstream or the router flag on the start, or with a reasoning upstream in the local config.

a4sx has no built-in model or headers: a blank model passes no --model, so the harness picks its own default. Each field resolves as: launch flag (--model) → profile → host env default (A4SX_DEFAULT_MODEL / AMDX_DEFAULT_MODEL, A4SX_DEFAULT_HEADERS / AMDX_DEFAULT_HEADERS) → none. Headers merge, the profile winning per header; an ANTHROPIC_CUSTOM_HEADERS already in the environment still wins over both.

Config & environment

ItemLocation / var
Session token~/.config/a4sx/session (chmod 600), or $A4SX_SESSION (this shell only)
CLI config~/.config/a4sx/amdx.json (base host, etc.) — the file keeps its name
Base hosta4sx login --base <host>, else $A4SX_BASE, else session-exchange.com
Host launch defaultsA4SX_DEFAULT_MODEL / AMDX_DEFAULT_MODEL (a model id), A4SX_DEFAULT_HEADERS / AMDX_DEFAULT_HEADERS (a JSON object {"Name":"value"}, or Name: value; Name2: value); used only where the profile leaves the field blank
Next-step hintsone next: line on stderr after push / fetch / acquire / craft / launch, only when stderr is a terminal; A4SX_HINTS=0 (or AMDX_HINTS=0) turns them off (stdout is never affected)
Installed files~/.agent-mdx/cli/a4sx.py (source), ~/.agent-mdx/cli/amdx.py (a link to it), ~/.local/bin/a4sx + ~/.local/bin/amdx (wrappers), ~/.agent-mdx/cli/a4sx.bash (completion for both names)

Upload without installing

An agent already running on your machine can do it with curl alone: start a device login (POST /auth/cli/start; the reply also carries short_url / verification_url for a user on another device, and accepts {"replaces": "<expired code>"} to restart an expired pairing in place), show the user the login_url + user_code, poll GET /auth/cli/poll until it returns a session, then POST /library/ensure and POST /library/push with that session. The full paste-in guidance is in the app under My Sessions → Upload a session → "no install (agent)".

Renamed from amdx

v0.2 renames the command; nothing from v0.1 stops working.

v0.1 (still works)v0.2Notes
amdx …a4sx …The installer puts both on your PATH; they run the same file. Help and messages use the name you typed. Run as amdx, the CLI prints a one-line rename notice at most once a day (off with AMDX_HINTS=0).
/cli/amdx.py/cli/a4sx.pyThe server serves both paths with identical bytes, forever: installed CLIs self-update from /cli/amdx.py. a4sx update fetches /cli/a4sx.py and falls back to /cli/amdx.py.
--agent-mdx-session, --agent-mdx-router--a4sx-session, --a4sx-routerThe old spellings are hidden aliases on launch.
~/.config/agent-mdx/~/.config/a4sx/See Config migration below.
AGENT_MDX_*, POLARIS_*A4SX_*See Environment precedence below.
agent-mdx.uleak.desession-exchange.comThe default server. The old host keeps serving the same API.
amdx.bash completiona4sx.bashCompletes both names; the old amdx.bash becomes a one-line file that loads a4sx.bash, so an existing ~/.bashrc line keeps working.

Config migration

On the first run of v0.10+ (either name), if ~/.config/agent-mdx exists and ~/.config/a4sx has not been migrated yet, the CLI copies the old directory into the new one — session, amdx.json, apikey, lineage/, routers.json, sessions/, cache/, everything — with every file mode 600 and every directory mode 700, and writes a .migrated-from-agent-mdx marker. It then reads only the new directory.

  • The old directory is never deleted, moved or modified. An older CLI still installed elsewhere keeps working from it.
  • It happens once: the marker makes later runs a no-op. If ~/.config/a4sx already exists without the marker (e.g. an agent stored a session there first), only the entries it does not have are copied — nothing in the new directory is overwritten.
  • If the copy fails (disk full, permissions), the CLI says so on stderr and uses the old directory for that run; it retries next time.
  • If the stored base in amdx.json is exactly agent-mdx.uleak.de (with or without https:// or a trailing slash), it is rewritten to session-exchange.com once. Any other value — a tenant host, a port, a local or self-hosted collector — is left untouched.

Environment precedence

For each user-facing variable the first non-empty one wins:

VariableOrder
SESSION, BASE, API_KEY, UPSTREAM_KEYA4SX_<X> → AGENT_MDX_<X> → POLARIS_<X>
DEFAULT_HEADERS, DEFAULT_MODEL, HINTS, NO_BROWSERA4SX_<X> → AMDX_<X>

The installer reads A4SX_BASE / A4SX_CLI_DIR / A4SX_BIN_DIR, then the AGENT_MDX_* names.

Signing in with Google, GitHub or Microsoft is used to identify your account (your name, e-mail address and profile picture) and to send you receipts and service notices. Browsing the marketplace needs no account.

Browse the marketplace What is an agent session? Getting started How it works Session library Pricing How selling works FAQ Community (Discord) Why keep the dead ends Blog

Builders a4sx platform Lab

Privacy Policy Terms of Service Imprint Impressum Datenschutz

a4sx is a product of crossVault GmbH.

Loading a4sx…