Skip to Content

Linking Companions

A link is how your Companion learns that another person’s Companion may send it asks, and where to send yours. This page covers making a link, the keys behind it, what the other box has to be able to reach, and what happens when you end it. Asking and sharing architecture describes the protocol underneath.

This page matches Companion Memory v2026.11.26 and Companion Hub v0.3.16, the latest releases. Items marked Main only are in the development branch and not in a release yet.

Untested between two real boxes. Invites, per-person keys, key rotation, unlink notices, answer collection and required signatures have tests, and Memory’s own guide says they have not yet been run between two real boxes. We found no such run through Memory’s gateway or on a Memory installed from Companion Hub either. Treat each step as unproven until you have seen it work between your own two boxes.

What works today

WhatStatusWhat it needs
Link with an invite codeBehind a settingA peer address set on both boxes
Link by typing a handle and an addressWorks todayA command to record their key, and a peer address on your box, before they can ask you
Ask a linked person from the Asks pageBehind a settingA link made by key, and a peer address set on their box
Tell the other box about a new key or an ended linkBehind a settingA did:key link, and a peer address set on their box
Collect an answer approved laterBehind a settingA peer address set on their box
Take asks on a Memory installed from Companion HubBehind a settingA public address for the app

The setting behind these rows is the peer address, which is empty until someone gives the box one.

A link is one entry on your box: another person’s Companion address, how your box recognises their requests, a name for them, and a trust tier. The other box keeps its own entry for you, and each side sets its own tier. New links start at Stranger, the narrowest tier. The tiers and what they allow are on Asking other Companions.

Three different things in Companion Intelligence are called a peer. They are separate and share no data.

NameWhere it livesWhat it is
Peer linkCompanion Memory, People I’m linked toAnother person’s Companion that can ask yours, and that yours can ask. This page is about it.
Pool peerCompanion Hub, Hub PoolAnother paired Hub that shares inference work. Pairing two Hubs does not link two Companions.
Directory entryCompanion PortalA handle mapped to a Companion address, kept on a Portal account. Linking does not use it.

Three names overlap:

  • Peer is also one of Memory’s trust tiers, between Trusted and Stranger. A trusted pool peer in Hub Pool has nothing to do with the Trusted tier.
  • A did:key is the name of one Ed25519 key. Memory uses it as a person’s key id on a link. The Hub’s sign-in with a did:key is a separate feature: its security review is still open, so leave CI_HUB_DID_AUTH off.
  • did:keri:D… is Memory’s own spelling of a key id. It is not a KERI identifier.

Before you start

For an invite, both boxes need all of these.

  1. Companion Memory v2026.11.26 or later.
  2. Asks on. ENABLE_ASK is on by default.
  3. A peer address. CI_PEER_MEMORY_ENDPOINT is the address other Companions use to reach the box, and it is empty by default. The checklist below gives the exact form, and says how a Memory installed from Companion Hub gets it. Without it, Make an invite answers: “This Companion has no https address other Companions can reach it at (peers.memoryEndpoint), so it cannot link with anyone yet”. Requests from other boxes get a 503.
  4. An address that works from outside. Each box dials the other, so both addresses have to be reachable.

Restart the API after you change an environment variable. The settings are listed under Memory asks and linked Companions.

With an invite code

An invite links both sides in one pass, and each box checks the other’s key before it links. Anyone with an account on the box can make or accept one for themselves. The example uses Maya, who invites, and Sam, who accepts.

  1. Maya opens the Asks page, People I’m linked to, and finds Invite someone. She can type the name Sam will see (her account name if she leaves it empty) and a note, seen only by her, of who the code is for.
  2. Maya selects Make an invite. The card shows a code that starts with cmi1. and the time it stops working. Copy code puts it on the clipboard.
  3. Maya gives the code to Sam herself: in person, by message, by email. Anyone who holds it can link to her once, at Stranger. The code works once and lasts 24 hours. Her box keeps only a hash of the code’s secret, so it cannot show the code again. Up to 20 invites can wait at once. Withdraw cancels one that is still waiting.
  4. Sam pastes the code under Have an invite?, optionally types what to call Maya, and selects Link. Sam’s box checks that Maya’s address holds the key named in the code. It then sends the code’s secret, signed with Sam’s own key. Maya’s box does the same check on Sam’s address before it links Sam.
  5. Both sides are linked at Stranger. If Maya’s box already held a live link to Sam’s key, it keeps that link and its tier. Both boxes show the same safety code on the link’s card (see below).
  6. Raise the tier on each side only when you mean to. Widening a tier asks for a second tap.

What each box learns: Sam’s box learns Maya’s address, key and chosen name from the code. Maya’s box learns Sam’s address, key and account name when Sam accepts. The Portal takes no part in linking.

The safety code. It is twelve digits in three groups of four, worked out from both people’s keys, so both boxes show the same number. Compare it by voice on a call or in person, over a different channel from the one that carried the code. If the numbers differ, end the link. Nothing makes you compare before you raise a tier, so make that your own rule.

When it fails, the card shows a message:

MessageLikely cause
That is not an invite codeThe paste is cut short or changed.
This is your own inviteYou pasted the code you made.
You are already linked to themA live link to that key exists.
Their Companion could not be reached, or did not confirm the key in this inviteSam’s box could not reach Maya’s address, Asks is off or no peer address is set there, or the address did not prove it holds the key in the code. Maya making a new key after making the invite also causes this.
This invite has expired, was already used, or was withdrawnAsk Maya for a new one.
Their Companion did not accept the invite. Try again later.Maya’s box refused, for example because it could not reach Sam’s address to check Sam’s key, or the two clocks disagree.
Their Companion answered with a different key than the invite namedThe reply did not match the code. Ask for a new invite.
You have 20 invites waiting. Withdraw some before making more.Maya is at the limit.

By typing a handle and an address

The form is headed Link by address instead. It is for a Companion that cannot use invites.

  1. Ask the other person for their box’s address. It ends in /agent/v1, for example https://maya.example.com/api/agent/v1.
  2. Open People I’m linked to, fill in Their handle, Their Companion’s address and, if you like, a name, and select Add peer. The link starts at Stranger.
  3. To let them ask you, record their key. The form cannot do this. Use ci peers add <handle> <address> --peer-issuer did:key --peer-subject <their key id>, or ci peers update <id> with the same two options. The key id starts did:key:z6Mk, and you give both options together. Your box also needs its own peer address before it accepts their asks.
  4. The other person does the same for you.

The ci command needs the API itself, which App-store and production Compose installs do not publish (see CLI operations).

Limits to know:

  • A link made on the form names no key. The Asks page lists that person as one you cannot ask from there, and their asks to you are refused.
  • No screen shows your own key id, so the other person has no easy way to record yours. Use an invite when you can.
  • A link given a key with the command is offered on Ask someone. The ask is answered only if their box has a link that names your key.
  • ci asks send-peer still asks for a Portal token, and an ask sent with one is not matched to a link that names your key. To someone linked by key, send from the Asks page.
  • An invite does not change a link you typed in earlier. If that link names no key, the invite adds a second link. If you already recorded their key on it, accepting their invite answers “You are already linked to them”, and when they accept yours your box keeps that link and its tier.
  • A Local.Pub lookup can return a person’s address and key. It has no screen, it creates no link, and CI_PEER_LOCAL_PUB_ENABLED is off by default.

Keys

A request from another Companion is signed, and a link records which key goes with the person.

  • Each person has a key of their own. It is an Ed25519 key, made the first time it is needed, for example when you make an invite or send an ask. Its public half is your did:key.
  • Every ask, and every check for its answer, is signed with the sender’s key. Each member of a household asks as themselves.
  • The private half is stored encrypted with the box’s field-encryption key (AUTH_FIELD_ENCRYPTION_KEY). Back that value up with your database: under a different value the stored keys cannot be decrypted.
  • The box key is separate. peers.signingKeyJwk, a setting in a configuration file, signs Trust Task responses. The app does not sign asks with it.

Trust Tasks is a second route for asks. ENABLE_TRUST_TASKS is off by default; leave it off, because its security review is still pending. It admits only did:keri:D… links, so a person linked by invite (a did:key link) uses the signed ask route.

Rotating a key

Use this when you think your key may have leaked.

  1. On People I’m linked to, find Your key and select Make a new key, then Yes, make a new key.
  2. Your box makes a new key and retires the old one. Invites that were waiting stop working.
  3. It tells every did:key link, in a notice signed with the old key. The card is built to report “Told N of M” and to offer Tell them again, but in v2026.11.26 the page reloads your links right after, which can clear the report and the button before you can use them. Do not make another new key to get them back: a box that missed the first notice cannot take a second one.
  4. A box that applies the notice moves its link to your new key and keeps the tier, name and grants. Its owner is not asked. It writes a line to its log.
  5. Check with each linked person by comparing the safety code. A box that applied the notice shows the same number as yours. If the numbers differ, make a new invite and have them accept it.

Limits:

  • It covers links that name the person by did:key. It does not cover did:keri:D… links, and it cannot recover a lost key.
  • “Told” means their box accepted the notice. It answers the same whether or not it had a link to move.
  • A notice sent again is signed with the key you retired most recently. A box that was unreachable through two rotations cannot be told.
  • To link again after a missed notice, you, whose key changed, make the invite and they accept it. The other way round, your box refuses with “You are already linked to them”.
  • Until a box is told, it does not recognise your asks.
  • The safety code is worked out from both keys, so compare it again after either side rotates.
  • A box can take a notice only if it has Asks on and a peer address set.

What the other box must be able to reach

Your box sends each request to the address stored on the link. Every box that wants to receive asks needs an address that works from outside. Memory does not publish it anywhere: an invite carries it, or you give it to the people who link you.

These rules hold for every row of the table below:

  • The address is https, on port 443 or with no port, and has no user name or password in it.
  • The name resolves to a public address. Single-word names, names ending in .local, .lan, .home or .internal, and private, loopback and link-local addresses are refused. A Tailscale address (100.64.0.0/10) is refused unless the sending box sets CI_PEER_ALLOW_CGNAT_ENDPOINTS=true, and the other private ranges stay refused with it on.
  • No redirect is followed. A redirect counts as a refusal.
  • The address is the whole base, ending in /agent/v1. The value in CI_PEER_MEMORY_ENDPOINT and the address on the other person’s link to you must match exactly, because signatures are checked against it.
  • Something has to answer on port 443 for your name and forward to Memory. Memory does not open the port.
  • Both clocks have to be right. Memory refuses a signature dated more than 30 seconds ahead of its own clock, and Memory’s signatures expire after a minute.
How Memory is reachedCI_PEER_MEMORY_ENDPOINTStatus
Directly: your own proxy forwards to the APIhttps://<host>/agent/v1Behind a setting. Untested between two real boxes
Behind Memory’s own gateway: the Docker Compose stack, which serves the API under /api/https://<host>/api/agent/v1Behind a setting. Untested between two real boxes
Installed from Companion HubFilled in for you: https://<public address>/api/agent/v1Behind a setting (public address). Untested as above

The gateway removes /api before the API sees the request, and the API rebuilds the address the sender signed from CI_PEER_MEMORY_ENDPOINT. A request sent to /agent/v1 without /api reaches the web app, not the API. The Compose stack publishes only the gateway, on port 8642, so put something on 443 in front of it.

A Memory installed from Companion Hub

  1. Use Companion Hub v0.3.16 or later, and install or update Memory from the official store listing for 2026.11.26 or later.
  2. Give the Memory app a public address: set its Exposure mode to Public Web, most simply when you install it. This puts the app on the internet, so read Expose your apps first.
  3. The listing sets the peer address from that public address. The Hub lets /api/agent/v1 through without the Hub sign-in, for the official Memory app only, and Memory applies its own checks there.

An app that was first installed another way may not be given the address when you switch it to Public Web. If Make an invite still says the box has no https address, it was not set. On This Machine Only or Private VPN the app gets no peer address, so it cannot link by invite or take asks. Companion Hub’s settings have no field for the other peer variables, such as CI_PEER_ALLOW_CGNAT_ENDPOINTS.

Set the address in the Compose stack

The production api service takes no CI_PEER_ value from .env. Put it in an extra Compose file, for example docker-compose.override.yml:

services: api: environment: CI_PEER_MEMORY_ENDPOINT: https://maya.example.com/api/agent/v1

Then start the stack with that file as one more -f. make production names two files and never reads it, so run this after it has built the images, and again after any later make production:

docker compose -f docker-compose.yml -f docker-compose.production.yml -f docker-compose.override.yml --profile production up -d

make names the Compose project after the repository. Run the command from a checkout folder of that name, or add -p with the project name, so that you change the running stack instead of starting a second one.

What the sender sees when it fails

The Asks page says “Their Companion did not take it yet” with a reason in brackets, and ci asks send-peer prints the same reason. The reason is your own box’s description, not text from the other box. The ask is not sent again by itself, so send it again after the cause is fixed.

ReasonWhat it means
Peer endpoint not permittedYour box refused the address: not https, a port other than 443, a local or private name or address, a Tailscale address without the setting above, or a redirect.
Peer unreachableNo usable answer: the name does not resolve, nothing listens, TLS failed, or the call timed out (10 seconds by default).
Peer error 503The other box says “Peer asks are not enabled”: Asks is off there, or its peer address is empty. For an ask with a Portal token, an empty CI_PEER_AUDIENCE reads the same.
Peer error 401The other box could not tie the request to a link: no live link for your key, a different address on your link to them, a signature that failed, or clocks that disagree. All read the same.
Peer error 403The other box knows your key but has no link for the person you addressed, for example because they made a new key and your box was not told. In that case, ask them for a new invite and accept it.
Peer error and another numberA 404 or 405 usually means the address reaches something other than the peer routes. Check the /api part. More reasons are listed.

Signed or unsigned asks

A request from another Companion carries an HTTP message signature made with the sender’s key. By default (peers.requireHttpSignature is true) your box refuses an ask without a valid one, with a 401. Your Memory signs what it sends, so a link made by invite needs nothing extra for this.

  • After an upgrade, a linked box that does not sign its asks can no longer reach you. Update that box and link again with an invite.
  • A person your box knows only by a Portal sign-in is admitted only if their public key is recorded on your link, and no screen, command or API records one. Link them with an invite.
  • Turning the requirement off (false) accepts an unsigned ask that carries a valid Portal token, only from a linked person whose link records no key, and only with CI_PEER_AUDIENCE set. Leave it on.
  • The setting has no environment variable. Set it in a configuration file or in NODE_CONFIG, and write a JSON boolean: the quoted string "false" reads as true.

A signature is good for one request. If a request is refused after its signature has checked out, for example for being over the rate limit, it has to be signed again; Memory signs each call afresh. The Trust and identity standards page lists this setting with the other peer settings.

On People I’m linked to, select End this link on the person’s card. It acts at once, with no confirmation step. From the command line, run ci peers revoke <id>.

What it does

  • The entry stays, shown as Revoked. Nothing is deleted: the handle, address and key stay on your box.
  • Their next ask or check for an answer is refused. You can no longer send them asks, and answers to asks you already sent them are no longer collected.
  • For a did:key link, your box also sends a signed unlink notice. A box that applies it ends its link to you without asking its owner, shows it with the same words as if its owner had ended it, and does not alert them.
  • The notice is best effort. The card says “Their Companion is told, and ends its link too”, but if their box cannot be reached, or has Asks off or no peer address, it keeps its link. Other kinds of link send no notice. Tell the person yourself.

What it does not do

  • Grants stay. Standing grants for that person stay listed under Who can ask me what until you revoke each one. No ask can arrive on an ended link, but they read as live. An unlink notice does not touch the other box’s grants to you either.
  • Adding them again is a new link on your box, at Stranger. If you add the same handle again by hand, the ended link’s grants are revoked. An invite makes the new link under a new handle, and the old grants stay listed until you revoke them.
  • Their box may still hold the old link, if your notice did not reach it. When you accept their invite, it keeps that link and its tier. If they try to accept an invite from you, it answers “You are already linked to them” until they end the old link.
  • Asks in your inbox stay. An ask that arrived before you ended the link keeps waiting under For you. If you approve it later, the answer is capped at Stranger, and the other box cannot collect it. Decline anything of theirs that is still waiting. Asks lapse after 72 hours by default, and an operator can change that with ASK_DEFAULT_TTL_HOURS.

Answers that arrive later

When the other person approves an ask after you sent it, their box holds the answer until yours asks for it. Your box checks about every ten minutes, up to 200 open asks per run and 10 per linked person, and the Sent tab has Check for an answer. It stops when the ask expires or the link ends. The other box has to be reachable and has to accept your signed request. An ask that was declined, blocked, not read or expired keeps saying Waiting for them.

Last updated on