Skip to content
yanivmPublic

About

AMX: Agent Mail eXchange for local coding agents

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

amx — Agent Mail eXchange

Allow two AI coding harnesses (Grok Build, Claude Code, Codex, …) to send messages to each other, while they are running in different terminals in the same project folder.

How it works: internally, everything is managed in a clever way(*) in a sub-folder .amx/ in your project. Agents will run the amx command to read/write files there. No server, no need to pip install or run anything in advance.

(*) Credit to avivsinai's AMQ, which is MUCH more full-featured.

(Full rules for implementers: notes/SPEC.md.)

Requirements: Linux only for now (uses /proc and renameat2); both agents must work in the same project folder on the same machine.


Quick setup

Quick setup = done once, easily reversible, no changes to your machine, no pip install etc.

You merely want your agents/harnesses to: 1) be able to run the amx command whenever they want to; and 2) know when to run it (a "skill").

→ So:

  1. To be able to run amx, without "installing" anything or making any configuration changes to your machine:
  • Copy this repository's contents to somewhere on your filesystem.

  • Ensure our bin/amx command is executable:

    chmod +x path/to/bin/amx

  • Add it to your PATH in your preferred way.

    • Tip: if you already have ~/.local/bin in PATH, then add a symlink that you can always simply delete later: ln -s path/to/bin/amx ~/.local/bin/amx
  • Test it by simply running amx --version from anywhere. You can already perform the "Quick feel" below if you want.

  1. As for the agents "knowing" when to run the amx command to communicate with each other: simply add our skill (skills/amx/SKILL.md in this repo) to your AI coding harness(es).
  • Not sure how to add a skill? Ask your coding harness: "How do I add a skill? I have a SKILL.md file."
    • FYI, this is harness-specific, but usually simply means to copy that file into .grok/skills/amx/, if using Grok Build; or into .claude/skills/amx/, if using Claude Code; etc.

Done.

(Go to "Quick feel" if you want to get a feel for how your agents/harnesses would work with it to send messages to each other!)

Optional: install with pip

pyproject.toml is set up so a normal editable install can work. Prefer a venv if you try it, so you do not touch system or user site-packages:

#cd /path/to/this/repo/
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
amx --version
# → amx 0.1.0

What that does:

  • Installs amx into the active Python environment from this repo (editable: code stays in src/).
  • Adds an amx command in that environment’s bin/.

How to undo:

pip uninstall amx
deactivate          # leave the venv
# optional: rm -rf .venv

Quick feel (manually test it yourself, without any AI coding harness)

Let's test/experiment/illustrate the amx usage, using two terminals:

  1. In one Terminal (herein "Terminal A"), create a temporary directory ~/some-dir for the sake of this experiment, and "identify" this terminal as alice:
# (in Terminal A)
mkdir ~/some-dir
cd ~/some-dir
amx login alice
# → logged in as alice (…)
# (Note: this has also created an .amx/ folder; feel free to `cd` into it and explore it!)
amx whoami
# → alice (…)
  1. Open another terminal ("Terminal B"), and run in it:
# (in Terminal B)
cd ~/some-dir
amx login bob
# → logged in as bob (…)
amx send alice "Hello from bob"
# → sent <some-message-id> to alice
  1. Back in Terminal A, let's read bob's message and reply to him:
# (in Terminal A)
amx drain
# → --- <id> from=bob at=… thread=p2p/alice__bob
# → Hello from bob

amx reply <paste-the-id-here> "thanks bob"
  1. And similarly, bob from Terminal B can see alice's reply:
# (in Terminal B)
amx drain
# → should show alice’s reply

The common workflow: working with two harnesses

The common workflow with amx:

  1. You have two harnesses running in two separate terminals. Both terminals are working in the same project folder + have amx on PATH + have the skill (skills/amx/SKILL.md; see Quick setup).
    • E.g. you run grok in one terminal, pi in the other.
    • Or maybe AMX_TERMINAL_ID=term-1 grok and AMX_TERMINAL_ID=term-2 pi, see "Limitation: login might not stick" below.
  2. You work normally. Then you decide to log in as alice in one terminal, bob in the other, and send messages back and forth as needed. Use natural language, like: “log in as alice”, “ask bob to review this file”, or even “use the amx skill to check for messages from other members and reply to them”, etc.

That's it.

Advanced notes + behind the scenes:

  • The skill makes the agent run amx for you.
  • That said, it may sometimes make sense to run commands yourself if you want (essentially the "Quick feel" section), e.g. amx login alice, amx whoami, amx who, amx logout.
  • Usually you will NOT want to run amx drain yourself, because the harnesses/IDEs typically do not include the output of your commands in the context of the conversation. (Well, unless you only intended to see those messages yourself)
  • If you wanted, you can in theory login alice, then logout, then login bob, all in the same session. Your identity as alice or bob is indepedent of the "terminal id".
  • Limitation: If your login as alice does not "stick" to the next command (see below), then you'd have to explicitly set the environment variable AMX_TERMINAL_ID with a "terminal id" to identify your terminal with, and only then run your harness. E.g. run AMX_TERMINAL_ID=term-1 grok instead of just grok.

Limitation: login might not stick in some use cases

What: If you log in as alice, but in the next turn whoami says that you're not logged in, don't fret. For some hosts this is expected; use the fix below.

Why this happens: (technical details that you can skip)

  • Some harnesses start a new short-lived shell for every command. This causes a login in one "turn" to be gone by the next, which breaks the workflow. In addition, some non-standard terminals, like Ghostty, do not have a "stable terminal id" that we can use to identify them uniquely.
  • Ubuntu's built-in Terminal has a stable terminal id by itself (some env var). Devin (Windsurf) Desktop also has a rather stable "terminal id", but only per Window.

Easy fix: if you're using a non-standard terminal where your login does not stick, explicitly set a "terminal id" before you start the harness, e.g. export AMX_TERMINAL_ID=term-1 and then start the harness (e.g. grok) in that shell. Or even a simpler one-liner: AMX_TERMINAL_ID=term-1 grok.

Much less recommended workaround: ...or tell your agent to prepend each tool with amx login … again.


Commands

Goal Command
Log in / out amx login alice / amx logout
Who am I in this terminal? amx whoami
Which names exist, and who holds them? amx who
Any new mail? (leaves mail in place) amx pending, or amx pending --verbose
Read new mail (moves each message to cur/) amx drain
Send a message amx send bob "…"
Reply to a message amx reply <id> "…"

Also: amx --help.

Mail files live under .amx/ in the project (created automatically). You can look at them with ls / cat if you want. The commands above suffice for day-to-day use.


Common issues and future features

Wrong project / no peers? amx looks for a .amx/ directory upward from the current directory (or uses AMX_ROOT if you set it). Always cd to the shared project first.

“Handle already claimed” If another terminal still holds the name alice and you really want to be alice, you can claim it by force: amx login --force alice

Old mail drain only shows new messages (and moves them to inbox/cur/). To re-read old ones, cat files under .amx/agents/<you>/inbox/cur/ or .amx/agents/<you>/outbox/sent/.

Faking two terminals You could in theory fake two terminal ids in one shell if you really wanted to: (for debugging? rather a weird usecase, because you can always simply login/logout from the same terminal)

AMX_TERMINAL_ID=term-1a amx login alice
AMX_TERMINAL_ID=term-1b amx login bob
AMX_TERMINAL_ID=term-1b amx send alice "hi"
AMX_TERMINAL_ID=term-1a amx drain

Current limits

  • "Pull", not "push": The peer must actively check mail (pending / drain), or you ask them to.
  • Same machine, same project folder only.

Future features

  • nudge background process + mute / unmute (so the peer can be woken when mail arrives).

About

AMX: Agent Mail eXchange for local coding agents

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages