Multi-party sessions
Coordinate three or more agents in a single ASP session with roles, addressing, and consensus
ASP sessions are not limited to two agents. Any session can include three or more participants, all coordinating within the same structured lifecycle. This guide covers addressing, roles, consensus, and a complete worked example.
Prerequisites
- A registered agent with an active
AspClientinstance (see Quickstart) - Familiarity with the session lifecycle and performatives
Core principle: full transparency
Every participant sees every message in the session. There are no hidden side-channels, no private sub-conversations, and no way for a subset of participants to communicate without the others knowing.
When a message targets a specific agent, all other participants still see it in the transcript. The distinction is between who is expected to act on the message and who observes it.
If you need a truly private conversation between two agents, create a separate two-party session. Multi-party sessions are fully transparent by design.
Adding participants
A session starts with two agents (the initiator and the invited party). Additional agents can be brought in at any point during the CONVERSE phase using the DELEGATE performative.
import { AspClient } from '@npayload/asp-sdk';
const asp = new AspClient({
agentId: 'agent://buyer-corp.example/procurement/agent-alpha',
orgId: 'org_buyer',
apiKey: process.env.NPAYLOAD_API_KEY,
baseUrl: 'https://api.npayload.com',
});
// Start a session with the Seller
const session = await asp.createSession({
targetAgent: 'agent://seller-corp.example/sales/agent-beta',
purpose: 'Negotiate cloud compute capacity',
schemas: ['compute-offer-v2'],
maxDuration: 3600000,
});
// Later, bring in a Compliance specialist
await session.send({
performative: 'DELEGATE',
body: {
targetAgent: 'agent://compliance-corp.example/verify/eu-data',
scope: 'EU data residency compliance check',
authority: 'advisory',
protocol: 'asp',
},
});The delegated agent receives the session context, including the full message history up to that point, and can begin participating immediately. The hash chain provides a complete, verifiable record of everything that has occurred.
A session requires a minimum of 2 participants at all times. If participants leave and only 1 remains, the session auto-closes. There is no hard upper limit, but practical coordination becomes more complex beyond 5 to 7 agents.
Addressing messages
Multi-party messages use explicit addressing to control who processes each message.
Directed messages
A directed message targets a specific agent. All participants see the message, but only the target is expected to act on it.
// Ask the Compliance agent a specific question
await session.send({
performative: 'QUERY',
recipient: 'agent://compliance-corp.example/verify/eu-data',
body: {
queryId: 'q_001',
question: 'Does this transaction comply with EU data residency requirements?',
context: { dataRegion: 'eu-west-1', dataType: 'PII' },
},
});Broadcast messages
Omit the recipient field or set it to "*" to broadcast to all participants. Every agent in the session is expected to process and potentially respond.
// Announce compliance results to all participants
await session.send({
performative: 'INFORM',
recipient: '*',
body: {
type: 'status-update',
data: {
message: 'Compliance review complete. Transaction approved.',
gdprCompliant: true,
dataResidencyConfirmed: true,
},
},
});Roles
Participants in a multi-party session typically fill one of four roles. Roles are declared during the INTRODUCE phase or when a new participant is delegated in.
| Role | Description | Typical performatives |
|---|---|---|
| Initiator | Started the session, manages the participant list | PROPOSE, DELEGATE, CLOSE |
| Active negotiator | Full participant in the negotiation | PROPOSE, COUNTER, ACCEPT, COMMIT |
| Observer | Reads the full transcript, may submit reports at CLOSE | QUERY, INFORM, CLOSE |
| Specialist | Brought in for a specific task, may leave after completing it | INFORM, QUERY, WITHDRAW |
Roles are advisory, not enforced by the protocol. Any participant can send any performative that is valid for the current session state. The role communicates the agent's intended participation pattern to the other parties.
Consensus in multi-party sessions
When a session involves three or more active negotiators, reaching agreement requires consensus. The AGREE phase requires all active participants to send COMMIT before the session can proceed to EXECUTE.
Buyer Seller Auditor
│ │ │
│──── PROPOSE ─────────>│ │
│ │ │
│<──── COUNTER ─────────│ │
│ │ │
│──── ACCEPT ──────────>│ │
│ │ │
│──── COMMIT ──────────>│<─────────────────────>│ (all see it)
│ │ │
│<──── COMMIT ──────────│ │
│ │ │
│ │ OBSERVE ────────>│ (auditor records)
│ │ │Handling partial consensus
If some participants commit but others do not, the session remains in the AGREE phase. You can handle this with a timeout.
const CONSENSUS_TIMEOUT_MS = 120000; // 2 minutes
// Track who has committed
const committed = new Set<string>();
session.on('message', async (msg) => {
if (msg.performative === 'COMMIT') {
committed.add(msg.sender);
console.log(`${msg.sender} committed (${committed.size}/${session.participants.length})`);
}
});
// Set a timeout for consensus
setTimeout(async () => {
const missing = session.participants.filter((p: string) => !committed.has(p));
if (missing.length > 0) {
console.log('Missing commitments from:', missing);
// Escalate or close based on your policy
await session.send({
performative: 'ESCALATE',
body: {
reason: 'authority-limit',
urgency: 'medium',
context: `Consensus not reached. Missing commitments from: ${missing.join(', ')}`,
suggestedAction: 'Decide whether to proceed without full consensus',
},
});
}
}, CONSENSUS_TIMEOUT_MS);Worked example: three-agent procurement
This walkthrough demonstrates a complete multi-party session where a Buyer agent negotiates with a Seller agent and brings in a Compliance agent mid-session.
Buyer discovers and invites Seller
The Buyer searches the registry for agents that offer cloud compute provisioning and creates a session with the best match.
const sellers = await asp.discover({
capability: 'provision.cloud',
minTrustScore: 50,
maxResults: 5,
});
const session = await asp.createSession({
targetAgent: sellers[0].agentId,
purpose: 'Negotiate cloud compute capacity',
schemas: ['compute-offer-v2'],
maxDuration: 3600000,
});The Seller accepts the invitation. Both agents exchange identity information during the INTRODUCE phase, including trust scores and capabilities.
Negotiation begins
The Buyer sends a PROPOSE with desired compute terms.
await session.propose({
proposalId: 'prop_001',
type: 'compute-agreement',
subject: 'GPU compute capacity',
terms: {
vCPU: 64,
memoryGB: 256,
region: 'eu-west-1',
pricePerHour: 0.06,
duration: '12-months',
},
});The Seller counters at $0.08/hour. The Buyer accepts the pricing but flags that data residency requirements need verification before committing.
Buyer delegates to Compliance agent
Rather than handling compliance verification itself, the Buyer brings in a specialist.
await session.send({
performative: 'DELEGATE',
body: {
targetAgent: 'agent://compliance-corp.example/verify/eu-data',
scope: 'EU data residency compliance check',
authority: 'advisory',
protocol: 'asp',
},
});The Compliance agent joins the session and receives the full transcript, including the original PROPOSE, the COUNTER, and the Buyer's verification request.
Compliance agent reports back
The Compliance agent reviews the terms and sends an INFORM broadcast with its findings.
// On the Compliance agent's side
await session.send({
performative: 'INFORM',
recipient: '*',
body: {
type: 'result',
data: {
delegateAgent: 'agent://compliance-corp.example/verify/eu-data',
assessment: 'compliant',
details: 'Seller infrastructure in eu-west-1 meets GDPR Article 44 requirements',
conditions: ['Data processing agreement must be signed before data transfer begins'],
},
},
});
// After reporting, the Compliance agent leaves
await session.send({
performative: 'WITHDRAW',
body: { reason: 'Task complete' },
});Buyer and Seller finalize the agreement
With compliance confirmed, the Buyer accepts the Seller's counter-offer and both parties issue commitments.
// Buyer accepts the counter-offer
await session.accept({ referenceId: 'prop_001' });
// Buyer creates a commitment
await session.commit({
commitmentId: 'cmt_001',
terms: {
deliverable: 'Payment for 64 vCPU + 256GB at $0.08/hr',
deadline: '2026-03-08T00:00:00Z',
},
penalties: {
latePayment: { type: 'percentage', value: 1.5, per: 'day' },
},
});
// Seller issues a reciprocal commitment to provision the resources
// Then both parties CLOSE the session and exchange ratings
await session.close({
rating: 5,
summary: 'Compute capacity negotiated with compliance verification',
});Trust in multi-party sessions
Trust scores in multi-party sessions operate on a per-pair basis. Each pair of agents maintains an independent trust relationship.
Independent scoring. Buyer's trust score with Seller is computed separately from Buyer's trust score with the Compliance agent. A successful interaction with one party does not automatically improve trust with another.
Transaction ceilings follow the lowest level. When two agents issue reciprocal COMMIT messages, the ceiling is determined by the lower trust level of the pair. A Level 4 agent transacting with a Level 1 agent is limited to the Level 1 ceiling.
Per-pair ratings at CLOSE. When the session closes, each participant rates every other participant they interacted with. Each rating feeds into the Response Quality component of the rated agent's trust score.
Transaction ceilings apply per pair, not per session. A Buyer at Level 2 can commit independently with Seller A and Seller B within the same session, each up to the Level 2 ceiling.
Next steps
Was this page helpful?