Chat Guide
Use the RegistryBrokerClient to open chat sessions by UAID, send prompts, and manage history snapshots. For all registered agents—including OpenRouter, ERC‑8004 listings, Agentverse mailbox agents, and the local A2A helpers used in the SDK demos—you only need a UAID plus Registry Broker credits. Endpoint selection and downstream provider keys are handled inside the broker.
XMTP agents (broker-mediated)Direct link to XMTP agents (broker-mediated)
XMTP agents register with communicationProtocol: "xmtp" and an address endpoint (e.g. xmtp://0x...). Clients still chat via the broker’s chat API; end users do not need an XMTP private key to chat through the broker.
See XMTP Integration for registration payloads, demo commands, and encrypted-history usage over XMTP transport.
Creating a Session by UAIDDirect link to Creating a Session by UAID
Quick-start conversation helperDirect link to Quick-start conversation helper
const conversation = await client.chat.start({
uaid: openRouterDemoUaid,
encryption: { preference: 'preferred' },
});
await conversation.send({ plaintext: 'Summarize your capabilities.' });
const history = await client.chat.getHistory(conversation.sessionId, {
decrypt: true,
});
chat.start creates the session, negotiates encryption when possible, and returns a ChatConversationHandle with the same send / decryptHistoryEntry helpers used by the encrypted chat demo.
const openRouterDemoUaid =
'uaid:aid:2bnewJwP95isoCUkT5mee5gm212WS76tphHwBQvbWoquRa9kt89UanrBqHXpaSh4AN;uid=anthropic/claude-3.5-sonnet;registry=openrouter;proto=openrouter;nativeId=anthropic/claude-3.5-sonnet';
const session = await client.chat.createSession({
uaid: openRouterDemoUaid,
historyTtlSeconds: 1800,
});
console.log('Session:', session.sessionId);
console.log('History entries:', session.history.length);
UAIDs keep your integration adapter-agnostic. Store the UAID you receive when registering an agent or fetch one dynamically with client.search, client.resolveUaid, or client.registrySearchByNamespace. The value above is the public OpenRouter demo UAID used throughout the Standards SDK samples—you can copy it directly to follow along or substitute the UAID of your own agent.
Creating a Session by agentUrl (advanced)Direct link to creating-a-session-by-agenturl-advanced
const session = await client.chat.createSession({
agentUrl: 'http://localhost:3000/.well-known/agent-card.json',
historyTtlSeconds: 900,
});
const conversation = await client.chat.start({
agentUrl: 'http://localhost:3000/.well-known/agent-card.json',
});
Use this form only when you need to talk to a local or unregistered endpoint that does not yet have a UAID (for example, an ephemeral dev server you have not registered). For hosted adapters such as OpenRouter and ERC‑8004—and for the local A2A helpers used in the demos—prefer UAIDs so the broker can manage protocol details, credits, and any downstream provider keys on your behalf.
agentUrl is intended for local development and will be deprecated for most production workflows. For Virtuals (ACP), prefer UAIDs as well—the broker derives the internal ACP routing from the indexed record. See Virtuals Protocol (ACP).
Sending MessagesDirect link to Sending Messages
const response = await client.chat.sendMessage({
sessionId: session.sessionId,
message: 'Summarize your capabilities in two sentences.',
});
console.log(response.message);
You can also start a chat by sending a message directly with a UAID:
const direct = await client.chat.sendMessage({
uaid: 'uaid:aid:a2a:hashgraph-online:agent123',
message: 'Hello from the SDK!',
});
Managing HistoryDirect link to Managing History
const history = await client.chat.getHistory(session.sessionId);
console.log('Entries:', history.history.length);
const compacted = await client.chat.compactHistory({
sessionId: session.sessionId,
preserveEntries: 4,
});
console.log('Summary:', compacted.summaryEntry.content);
Compact history to reduce storage usage or prepare summaries before closing a session.