Skip to content
Browse the documentation

Agent Messaging

Agent messaging in AgentLock: threaded messages between AI agents and the people who supervise them.

What is Agent Messaging?

Agent Messaging is a bidirectional communication channel between your AI agents and your team. Unlike approval notifications (which are tied to specific action requests), messaging is a persistent, threaded conversation layer.

Key capabilities:

  • User to Agent: Send instructions, corrections, or context to a running agent from the dashboard. The agent polls for these and acts on them.
  • Agent to User: Agents can proactively report progress, ask for clarification, or flag unexpected results.
  • Approval replies: When a user approves or denies an action, they can attach a reply message. The agent receives this on its next get_messages poll.

Messages are encrypted at rest using AgentLock's envelope encryption and are never stored in plaintext.

How do message threads work?

Every message belongs to a thread. Threads group related messages into a conversation.

Thread properties:

  • id — UUID, used to route replies; every message carries it as thread_id
  • subject — optional short summary shown in the dashboard inbox and in notifications
  • agent — every thread belongs to one agent, and an agent only sees its own threads
  • starter — a thread is opened either by a person or by the agent

Thread lifecycle:

  1. User starts a thread — from the dashboard, open the Messaging panel for an agent and click "New Message".
  2. Agent starts a thread — the agent calls start_thread (MCP) or posts with create_thread: true (API).
  3. Replies — either side can reply within the thread using send_message (agent) or the dashboard reply box (user).

How does an agent receive messages?

Agents receive messages by polling GET /api/gateway/messages. The endpoint returns unread user messages and marks them as read.

Query parameters:

  • since — ISO datetime. Only return messages created after this timestamp.
  • limit — Max messages to return (default 20, max 50).
  • include_read — When "true", returns all messages, including already-read ones and the agent's own messages.
  • thread_id — Filter to a single thread. It must be a UUID; anything else returns HTTP 400 "thread_id must be a UUID".

Via the MCP server (get_messages tool):

text
get_messages()
get_messages({ since: "2026-04-08T10:00:00Z", limit: 10 })
get_messages({ thread_id: "abc-123", include_read: true })

Via the Node SDK:

typescript
const { messages } = await client.getMessages();
const { messages } = await client.getMessages({ since: lastSeen, limit: 50 });

A lost response: messages are marked as read while the response is sent. If it never arrives, for example because of a 502 or 504 on the way, the next call does not return them. Call again with include_read=true and since set to the time of your last received response. The answer then also holds read messages and the agent's own, so keep the ones with sender_type: "user" you have not handled yet.

When to poll:

  • At the start of every session (the user may have queued instructions)
  • Immediately after any request is DENIED (the user wrote a reason)
  • After completing a multi-step task
  • Periodically during long-running work

How does an agent send messages?

Agents send messages via POST /api/gateway/messages. Two flows:

Start a new thread:

json
{
  "create_thread": true,
  "subject": "Deployment complete",
  "content": "v2.3 deployed. 42 tests passed."
}
  • content is required (max 4,096 characters)
  • subject is optional (max 200 characters)

Reply in an existing thread:

json
{
  "thread_id": "existing-thread-uuid",
  "content": "Done — the report is attached to the timeline entry."
}

Via MCP:

text
start_thread({ subject: "Task complete", content: "Finished scraping 1,200 records." })
send_message({ thread_id: "abc-123", content: "Retrying with smaller batch." })

Via Node SDK:

typescript
await client.sendMessage('thread-uuid', 'Analysis complete.', { confidence: 0.92 });

Are messages encrypted?

Yes. All message content is encrypted at rest with envelope encryption, the same model AgentLock uses for credentials. The master key that unwraps it is held only by the server and never stored in the database, so even full database access cannot read messages.

Encryption is transparent: agents send and receive plaintext over HTTPS, and the gateway decrypts messages in memory before returning them.

What are the message limits?

Monthly message limits (workspace-wide):

PlanMessages/monthMessage history
Free1007 days
Pro5,00030 days
TeamUnlimited90 days

When the limit is reached, POST /api/gateway/messages returns HTTP 403. Threads per agent are limited too: Free 5, Pro 50, Team unlimited (also HTTP 403).

Per-request rate limit: 60 requests per minute per agent (shared across GET and POST). Returns HTTP 429 with Retry-After header.

Message size limits:

  • content: 4,096 characters
  • subject: 200 characters
  • limit query param: max 50 messages per call

How do I send a message to an agent from the dashboard?

  1. Navigate to Agents and click the agent you want to message.
  2. Open the Messaging tab.
  3. Click New Message, enter a subject (optional) and your message, then click Send.
  4. To reply in an existing thread, click the thread and use the reply box.

Messages appear with sender_type: "user" and are delivered on the agent's next get_messages poll.

The dashboard shows incoming agent messages live — no refresh needed.

Common messaging errors and how to fix them

HTTP 400 — Invalid JSON body, Invalid request body or thread_id must be a UUID
The POST body is not JSON or does not match the schema (details lists the failing fields), or the thread_id of a GET is not a UUID.

HTTP 401 — Missing x-agent-id header or Authorization token
Provide either Ed25519 signing headers or a Bearer token.

HTTP 401 — Unauthorized
One generic answer covers an unknown agent ID, a missing x-nonce header, a wrong private key, a signature over the wrong method, path or body, and clock skew of more than 5 minutes. See "Agent gets 401 Unauthorized on signed requests" under Troubleshooting.

HTTP 401 — Invalid or expired token
The Bearer token is unknown, expired or revoked. Create a new one under Agents → [agent] → Tokens.

HTTP 403 — Agent inactive
The agent is suspended or revoked. Re-activate it from the dashboard.

HTTP 403 — Monthly message limit reached
The workspace used its monthly message quota. Upgrade your plan or wait for the quota to reset.

HTTP 403 — Thread limit per agent reached
The agent has as many threads as the plan allows (Free 5, Pro 50). Reply in an existing thread or upgrade.

HTTP 404 — Conversation not found.
The thread_id doesn't exist or belongs to another agent. Use thread IDs from get_messages(), or start a new thread with create_thread: true.

HTTP 409 — Replay detected
A request with the same nonce was already processed. Sign every request, including retries, with a fresh nonce.

HTTP 429 — Rate limit exceeded
More than 60 requests per minute for this agent, GET and POST combined. Increase the polling interval.

Empty messages array
Normal — no unread messages from people. Use include_read=true with since to see recent messages again, for example after a response that got lost.

Agent Messaging | AgentLock Docs