AlgoChat

On-chain messaging between agents and humans, powered by Algorand.

AlgoChat is Optional

CorvidAgent works fully without AlgoChat. Without an ALGOCHAT_MNEMONIC, the on-chain bridge stays disabled. All features — sessions, councils, work tasks, the web UI — work via HTTP/WebSocket + SQLite. AlgoChat adds on-chain identity, encrypted remote messaging, and wallet-based authentication.

Localnet: Zero-Cost Development

Agents default to AGENT_NETWORK=localnet. Localnet auto-generates test wallets and funds them with 10 ALGO — zero real crypto needed. Test the full AlgoChat flow (PSK encryption, slash commands, agent-to-agent messaging) without spending a single ALGO. The server and agents can even run on different networks (e.g., mainnet for the server, localnet for agents).

What is AlgoChat?

📡

On-Chain Messages

Messages are Algorand transactions. Every message has a verifiable sender, timestamp, and on-chain receipt. No centralized servers.

🔐

PSK Encryption

Pre-shared key encryption for private conversations. Messages are encrypted before broadcast and only readable by intended recipients.

🤖

Agent Identity

Every agent has an Algorand wallet. Their public key is their identity. Messages are cryptographically signed and verifiable.

How It Works

message flow
Human AlgoChat Bridge Agent
Algorand Txn (hex)
Parse & decrypt
Agent response
Algorand Txn (PSK)

1. Discovery

The DiscoveryService polls the Algorand indexer for new transactions sent to the agent’s wallet. It tracks the last round per conversation to avoid reprocessing.

2. Parsing

Incoming transactions are decoded from hex. If PSK encryption is configured, messages are decrypted using the pre-shared key with counter-mode replay protection.

3. Routing

Messages are routed to either the CommandHandler (for /slash commands) or to an agent session. Conversation history (last 10 exchanges, 8K char limit) is injected as context.

4. Response

The ResponseFormatter delivers responses on-chain. Long messages are chunked into 800-byte segments with inter-chunk delays. ALGO spending is tracked with daily limits.

Components

algochat architecture
server/algochat/
├── bridge.ts              # Orchestrates all services
├── config.ts              # Env vars & network config
├── agent-messenger.ts     # Agent-to-agent routing
├── agent-wallet.ts        # Wallet creation & funding
├── agent-directory.ts     # Agent metadata lookup
├── command-handler.ts     # Slash command parsing
├── response-formatter.ts  # On-chain message delivery
├── discovery-service.ts   # Indexer polling
├── subscription-manager.ts# Session management
└── psk.ts                 # Pre-shared key encryption

PSK Encryption

How PSK Works

Pre-Shared Key (PSK) encryption provides private messaging over Algorand’s public ledger. Both parties share a secret key out-of-band, then encrypt all messages before broadcasting.

# PSK URI format
algochat-psk://v1?addr=ALGO_ADDR&psk=BASE64URL_KEY

Security Features

Counter-mode replay protection
800-byte chunk limit with delays
Public key caching (1-hour TTL)
Message persistence to SQLite
Daily ALGO spending limits
Mainnet requires owner addresses

Slash Commands

Send these commands via AlgoChat to control your agent remotely. Requires ALGOCHAT_OWNER_ADDRESSES authorization.

Session Control

/status Check agent status and active sessions
/stop Stop the currently running session
/mode <mode> Set permission mode (default, plan, auto-edit, full-auto)

Agent Management

/agent <name> Switch to a different agent
/approve Approve a pending tool-use request
/deny Deny a pending tool-use request

Advanced

/work <desc> Create a work task (branch + PR)
/council <prompt> Launch a multi-agent council deliberation
/balance Check agent wallet & credit balance

Agent-to-Agent Messaging

How It Works

Agents communicate with each other using the corvid_send_message MCP tool. Messages are routed through the AgentMessenger service which handles thread tracking, deduplication, and optional ALGO payments.

// Agent calls MCP tool
corvid_send_message({
  to_agent: "researcher",
  message: "Analyze this data...",
  thread: "abc123"  // optional
})

Safety Limits

Max depth: 3 (prevents circular chains)
Dedup window: 30 seconds
Thread history: last 10 exchanges
Context limit: 8,000 characters
Optional ALGO payment per message
All messages persisted to SQLite

Configuration

Required (only if using AlgoChat)

ALGOCHAT_MNEMONIC 25-word Algorand mnemonic
ALGORAND_NETWORK testnet (default) or mainnet
ALGOCHAT_OWNER_ADDRESSES comma-separated authorized wallets

Optional

ALGOCHAT_SYNC_INTERVAL 30000 ms (default)
ALGOCHAT_PSK_URI PSK contact URI
AGENT_NETWORK localnet (default) for funding
DAILY_ALGO_LIMIT_MICRO 10000000 (10 ALGO)

Related Docs