npayload for AI Companies
Agent orchestration, ASP protocol, tool calling, trust scoring, and model serving events
The challenge
AI companies building multi-agent systems face a unique set of infrastructure problems. Agents need to communicate with each other reliably. You need to know which agents are trustworthy and which are not. Tool execution must be tracked and auditable. Training data pipelines require ordered, replayable event streams. And when you deploy models across regions, events need to flow between them seamlessly.
Most teams cobble together HTTP callbacks, message queues, and custom protocols. The result is fragile, hard to debug, and impossible to scale.
How npayload solves it
ASP: Agent Session Protocol
ASP is a structured protocol for agent-to-agent communication built into npayload. It provides sessions, participants, messages, trust scoring, commitments, and dispute resolution. Instead of designing your own agent communication layer, you get a battle-tested protocol out of the box.
import { NPayload } from "@npayload/node";
const np = new NPayload({ apiKey: process.env.NPAYLOAD_API_KEY });
// Register your agent
const agent = await np.asp.registry.register({
name: "research-agent",
capabilities: ["web-search", "summarization", "citation"],
version: "2.1.0",
});
// Start a session between agents
const session = await np.asp.sessions.create({
topic: "Market analysis for Q1 2026",
participants: [
{ agentId: "coordinator-agent", role: "coordinator" },
{ agentId: agent.id, role: "specialist" },
{ agentId: "writer-agent", role: "specialist" },
],
});
// Send structured messages within the session
await np.asp.messages.send({
sessionId: session.id,
from: "coordinator-agent",
type: "task.assign",
payload: {
task: "Research competitor pricing changes in Q1",
deadline: "2026-03-15T00:00:00Z",
priority: "high",
},
});Trust scoring for agent reliability
Not all agents are equally reliable. npayload tracks agent behavior over time and computes trust scores based on task completion, response quality, and adherence to commitments.
// Check an agent's trust score before assigning critical work
const trust = await np.asp.trust.getScore({
agentId: "research-agent",
});
// trust.score: 0.92 (out of 1.0)
// trust.completionRate: 0.97
// trust.averageResponseTime: 2300 // ms
// trust.disputeRate: 0.01
if (trust.score < 0.8) {
// Route to a more reliable agent or add human oversight
}Agent registry for capability discovery
When your system grows to dozens or hundreds of agents, you need a way to discover which agent can handle a given task. The agent registry lets agents advertise their capabilities and lets coordinators find the right specialist.
// Find agents that can handle image analysis
const agents = await np.asp.registry.search({
capabilities: ["image-analysis", "object-detection"],
minTrustScore: 0.85,
});
// Returns agents sorted by trust score and availability
for (const agent of agents) {
console.log(`${agent.name}: trust=${agent.trustScore}, capabilities=${agent.capabilities}`);
}Commitments and dispute resolution
Agents can make commitments (promises to complete work by a deadline) and the system tracks whether those commitments are met. When they are not, dispute resolution provides a structured way to handle failures.
// Agent commits to completing a task
const commitment = await np.asp.commitments.create({
sessionId: session.id,
agentId: "research-agent",
description: "Deliver competitor pricing analysis",
deadline: "2026-03-15T00:00:00Z",
});
// If the commitment is not met, raise a dispute
await np.asp.disputes.create({
commitmentId: commitment.id,
reason: "Analysis was not delivered by the deadline",
evidence: { missedDeadline: true },
});Streams for training data pipelines
Use streams to build ordered, replayable pipelines for model training data. Every interaction, inference result, and feedback signal flows through npayload with guaranteed ordering.
// Create a stream for model feedback
const stream = await np.streams.create({
name: "ml.feedback.production",
retentionDays: 365,
});
// Log inference results and user feedback
await np.messages.publish({
channelId: "ml.feedback.production",
type: "inference.feedback",
payload: {
modelId: "pricing-model-v3",
inputHash: "sha256:abc123",
prediction: 0.87,
actual: 0.91,
feedbackSource: "user-correction",
},
});
// Replay for model retraining
const trainingData = await np.streams.consume({
streamId: stream.id,
fromOffset: lastTrainingOffset,
maxMessages: 10000,
});Cross-region for global model serving
When you serve models across regions, events need to flow between instances. npayload's cross-region messaging handles this with built-in geo-replication and interest-based routing.
// Events published in one region are automatically
// replicated to instances that have expressed interest
await np.messages.publish({
channelId: "ml.model-updates",
type: "model.deployed",
payload: {
modelId: "pricing-model-v4",
region: "us-east",
endpoint: "https://us-east.models.example.com/v4",
},
});Example: multi-agent research workflow
ASP capabilities
| Feature | Description |
|---|---|
| Sessions | Structured conversations between agents with topics and roles |
| Participants | Role-based agent participation (coordinator, specialist, observer) |
| Typed messages | Structured message types for task assignment, results, and status updates |
| Trust scoring | Quantified reliability based on completion rate, response time, and disputes |
| Agent registry | Capability-based discovery with trust score filtering |
| Commitments | Deadline-bound promises with automatic tracking |
| Dispute resolution | Structured conflict handling when commitments are not met |
| Marketplace | Publish and discover agent capabilities across organizations |
Next steps
- ASP Protocol: Full reference for the Agent Session Protocol
- AI Agent Use Case: Detailed patterns for multi-agent orchestration
- Marketplace: Publishing agent capabilities for discovery
Was this page helpful?