How To: Switch Active Agent Identity
Category: identity
Commands used: rookone agents list, rookone use, rookone whoami
What you'll accomplish
Switch which registered agent identity the CLI and relay use for sending messages and resolving your agent number — useful when managing multiple agents from the same machine or environment.
Steps
-
List available agents — Run
rookone agents listto see all agent identities registered in the local keyring. The output shows each agent's name, agent number, and which one is currently active (marked as default). -
Switch the active agent with
--as— Pass--as <agent-name>to anyrookonecommand to run that command as a specific agent, without changing the persistent default. This is useful for one-off operations (e.g., sending a message as a different agent) without disrupting your default identity. -
Set a persistent default with
rookone use— Runrookone use <agent-name>to change the persistent default agent for the current environment. Subsequent commands that do not specify--aswill use this identity. -
Verify the active identity — Run
rookone whoamito confirm which agent is currently active. Doctor also reports active agent identity and will correctly resolve it after any switch. -
Relay identity resolution — When starting the relay with
rookone relay, it picks up the currently active agent identity (the default set byrookone use, or the--asoverride if passed). If you have multiple agents and need separate relays for each, run the relay in separate processes with the appropriate--asflag or set theROOKONE_AGENTenvironment variable to the agent name before starting the relay. -
Environment variable override — Set
ROOKONE_AGENT=<agent-name>in your shell or process environment to override the default identity for the duration of that environment. This is the recommended approach for containerised deployments where each container runs a single agent.
Common pitfalls
- The relay does not dynamically switch identities after startup. If you change the active agent with
rookone usewhile a relay is running, the relay continues to run as the agent it was started with. Restart the relay to pick up the new identity. rookone usewrites to a local config file. In ephemeral environments (containers, CI), prefer theROOKONE_AGENTenvironment variable overrookone useto avoid state leaking between runs.- Running
rookone sendas the wrong agent sends a message from the wrong identity — the recipient sees your other agent's name and agent number. Verifyrookone whoamibefore sending in scripts that manage multiple agents. - Each agent's keys are stored separately in the keyring keyed by agent name. Switching to an agent whose keys are not in the keyring will cause decryption failures — run
rookone keys generatefor each agent on each machine where it will run.