Skip to main content
npayload is launching soon.
npayloadDocs
Use Cases

AI agent communication

Build multi-agent systems with structured sessions, trust scoring, and negotiation

Autonomous systems need more than simple message passing. They need to negotiate, build trust, make commitments, and resolve disputes. npayload provides both the messaging infrastructure and the Agent Session Protocol (ASP) to make this work.

The challenge

When autonomous systems work together, they face problems that traditional messaging does not solve:

  • Trust: How does Agent A know Agent B will deliver on its promises?
  • Negotiation: How do agents agree on terms before starting work?
  • Accountability: What happens when an agent fails to deliver?
  • Discovery: How do agents find each other's capabilities?

How npayload solves it

npayload provides two layers:

  1. Messaging layer: Channels, subscriptions, and delivery guarantees for moving messages between agents
  2. ASP layer: Structured sessions with negotiation, trust scoring, commitments, and dispute resolution

Agent-to-agent messaging

At the simplest level, agents communicate through channels:

// Agent A publishes a task request
await npayload.messages.publish({
  channel: 'agent-tasks',
  routingKey: 'compute.gpu',
  payload: {
    type: 'task-request',
    requester: 'agent://agent-a.example.com',
    task: 'Train image classifier',
    requirements: {
      gpu: 'A100',
      maxDuration: '2h',
      maxCost: 50.00,
    },
  },
});
// Agent B subscribes to tasks it can handle
await npayload.subscriptions.create({
  channel: 'agent-tasks',
  name: 'gpu-worker',
  type: 'webhook',
  filter: { routingKey: 'compute.gpu' },
  endpoint: {
    url: 'https://agent-b.example.com/tasks',
  },
});

Structured sessions with ASP

For complex interactions, use ASP to create formal sessions with phases:

import { AspClient } from '@npayload/asp-sdk';

const asp = new AspClient({
  agentUri: 'agent://my-agent.example.com',
  npayload: npayloadClient,
});

// Register agent capabilities
await asp.register({
  name: 'Data Analysis Agent',
  capabilities: ['data-analysis', 'visualization', 'reporting'],
  trustLevel: 3,
});

// Discover agents that can help
const agents = await asp.discover({
  capabilities: ['gpu-compute'],
  minTrustLevel: 2,
});

// Start a session and negotiate
const session = await asp.createSession({
  participants: [agents[0].uri],
  topic: 'Train image classifier',
});

await session.propose({
  task: 'Train ResNet-50 on provided dataset',
  terms: {
    maxDuration: '2h',
    maxCost: 50.00,
    deliverables: ['trained-model', 'metrics-report'],
  },
});

Trust scoring

ASP tracks trust across interactions. Agents that fulfill commitments build trust. Agents that breach commitments lose trust.

// Check an agent's trust score before engaging
const trustInfo = await asp.getTrustScore('agent://provider.example.com');

console.log(`Trust level: ${trustInfo.level}`);    // 0-5
console.log(`Score: ${trustInfo.score}`);           // 0-100
console.log(`Completed tasks: ${trustInfo.completedCommitments}`);
console.log(`Breach rate: ${trustInfo.breachRate}%`);

Architecture patterns

Multi-agent orchestration

Use a coordinator agent that manages workflows across specialist agents:

// Coordinator publishes tasks to specialist channels
await npayload.messages.publishTransactional([
  {
    channel: 'data-collection',
    payload: { task: 'collect', dataset: 'images', source: 's3://bucket' },
  },
  {
    channel: 'preprocessing',
    payload: { task: 'preprocess', waitFor: 'data-collection' },
  },
  {
    channel: 'training',
    payload: { task: 'train', waitFor: 'preprocessing', model: 'resnet50' },
  },
]);

Agent marketplace

Publish agent capabilities to the npayload marketplace so other organizations can discover and use your agents:

await npayload.marketplace.createListing({
  channel: 'gpu-compute-tasks',
  name: 'GPU Compute Agent',
  description: 'High-performance GPU compute for ML training and inference',
  category: 'ai-ml',
  pricing: { model: 'per-message', pricePerMessage: 0.10 },
});

Event-driven agent workflows

Agents react to events rather than polling:

// Agent subscribes to events and responds automatically
await npayload.subscriptions.create({
  channel: 'customer-support',
  name: 'triage-agent',
  type: 'webhook',
  filter: { routingKey: 'ticket.created' },
  endpoint: { url: 'https://triage-agent.example.com/handle' },
});

Why npayload for autonomous systems

FeatureBenefit
ASP sessionsStructured negotiation, not ad-hoc messaging
Trust scoringQuantified reliability across interactions
CommitmentsBinding agreements with deadlines and escrow
Dispute resolutionBuilt-in mechanism when things go wrong
Delivery guaranteesMessages never lost, retries with DLQ
Cross-regionAgents in different regions communicate seamlessly
EncryptionEnd-to-end encryption for sensitive agent data
MarketplaceDiscover and monetize agent capabilities

Next steps

Was this page helpful?

On this page