Inferensys

Glossary

JSON-RPC

JSON-RPC is a stateless, lightweight Remote Procedure Call (RPC) protocol that uses JSON for data encoding, defining a simple format for requests, responses, and notifications between client and server.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
AGENT COMMUNICATION PROTOCOLS

What is JSON-RPC?

JSON-RPC is a stateless, lightweight Remote Procedure Call (RPC) protocol that uses JSON (JavaScript Object Notation) for data encoding, defining a simple format for requests, responses, and notifications between client and server.

The protocol defines a minimal specification where a request object must contain jsonrpc, method, and params members, while a response object contains jsonrpc, result, and error. It supports batch requests for sending multiple calls in a single transmission and distinguishes between calls expecting a result and notifications that do not. This simplicity makes it highly suitable for agent communication where low overhead and clear semantics are prioritized over complex feature sets.

In multi-agent system orchestration, JSON-RPC provides a foundational request-response pattern for direct, synchronous task delegation between agents. Its language-agnostic nature allows heterogeneous agents written in different programming languages to interoperate seamlessly. While lacking built-in features for advanced patterns like publish-subscribe, it serves as a core building block upon which more complex agent coordination and orchestration workflows can be constructed, often layered over transport protocols like WebSockets or HTTP.

AGENT COMMUNICATION PROTOCOLS

Key Features of JSON-RPC

JSON-RPC is a stateless, lightweight Remote Procedure Call (RPC) protocol that uses JSON for data encoding. Its simplicity and language-agnostic nature make it a foundational protocol for structured communication between autonomous agents.

01

Stateless Request-Response Model

JSON-RPC operates over a connectionless, stateless model where each request from a client is independent and contains all necessary information for the server to process it. This aligns perfectly with the decentralized and autonomous nature of agent systems, where agents may join or leave the network dynamically.

  • Each request must include a method name and parameters.
  • The server's response pairs a result (or error) with the request's unique id.
  • This model simplifies agent design, as no session state needs to be maintained between interactions.
02

JSON Encoding for Interoperability

The protocol mandates JavaScript Object Notation (JSON) for all message structures. JSON's ubiquity as a data interchange format ensures maximum interoperability between agents written in different programming languages (Python, Java, JavaScript, Go, etc.).

  • Human-readable text format aids in debugging agent communications.
  • Wide library support across all major languages reduces implementation overhead.
  • The structured format enforces a clear contract for method names, parameter objects, and result objects, which is critical for agent coordination.
03

Structured Error Handling

JSON-RPC defines a standardized error object within responses, which is essential for robust multi-agent systems. When a procedure call fails, the server must return an error object containing a predefined code, a message, and optional additional data.

  • Predefined error codes (e.g., -32700 for Parse error, -32601 for Method not found) allow agents to programmatically handle common failures.
  • The error data field can contain agent-specific context for advanced recovery or logging within an orchestration layer.
  • This formalized error channel is distinct from a successful result, preventing ambiguity in agent decision-making.
04

Notifications (One-Way Messages)

Beyond request-response, JSON-RPC supports notifications—messages where the client does not require a response. This is a key feature for event-driven communication between agents.

  • A notification is a request object with a null id field.
  • The server must not reply, not even with an error.
  • This enables efficient publish-style messaging, such as an agent broadcasting its status update or emitting an event without blocking for acknowledgments.
05

Batch Requests for Efficiency

The protocol allows a client to send an array of multiple request objects in a single call. The server processes each and returns an array of responses (excluding notifications). This batch processing capability is critical for reducing network latency and overhead in agent orchestration.

  • Reduced round-trip time when an orchestrator needs to query or command multiple agents simultaneously.
  • Responses are returned in an array corresponding to the order of requests, maintaining clear mapping.
  • Notifications can be included in a batch; they generate no response entry, keeping the output concise.
06

Transport Agnosticism

JSON-RPC is agnostic to the underlying transport layer. While commonly used over HTTP, it can be implemented over WebSockets for full-duplex communication, Message Queues (like RabbitMQ or Kafka), TCP sockets, or even inter-process communication (IPC).

  • This flexibility allows it to integrate seamlessly into diverse multi-agent system architectures.
  • Agents communicating over a persistent WebSocket connection can achieve low-latency, bidirectional RPC and notifications.
  • Using a message broker as transport enables decoupled, asynchronous communication patterns common in agent swarms.
AGENT COMMUNICATION PROTOCOLS

JSON-RPC vs. Other Communication Protocols

A comparison of key technical features across common protocols used for inter-agent and service-to-service communication in multi-agent system orchestration.

FeatureJSON-RPCREST (HTTP)gRPCAMQP (e.g., RabbitMQ)

Primary Communication Pattern

Request-Response, Notifications

Request-Response (CRUD)

Request-Response, Streaming

Publish-Subscribe, Message Queuing

Message Encoding

JSON

JSON, XML, Plain Text

Protocol Buffers (binary)

Protocol-specific (binary, with headers), payload agnostic

Interface Definition

Informal (JSON schema optional)

Informal (OpenAPI/Swagger optional)

Formal (.proto files required)

Formal (exchange, queue, binding definitions)

State Management

Stateless

Stateless

Stateless (per call)

Stateful (broker maintains queues)

Connection Model

Connection-per-request or persistent

Connection-per-request (HTTP/1.1)

Persistent, multiplexed (HTTP/2)

Persistent, broker-mediated

Built-in Discovery

via naming resolvers)

via broker)

Native Streaming Support

client

server

bidirectional)

consumer flow)

Typical Use Case in MAS

Direct agent-to-agent procedure calls

Agent interaction with RESTful APIs

High-performance, typed internal agent communication

Decoupled, asynchronous event broadcasting

JSON-RPC

Frequently Asked Questions

JSON-RPC is a foundational protocol for agent communication, enabling structured request-response interactions. These FAQs address its core mechanics, use cases, and role in multi-agent orchestration.

JSON-RPC is a stateless, lightweight Remote Procedure Call (RPC) protocol that uses JSON for data encoding. It defines a simple format for a client to request the execution of a method on a server, and for the server to return a response. A request is a single JSON object containing a jsonrpc member (specifying the protocol version, e.g., "2.0"), a method (the name of the procedure to invoke), params (an array or object of arguments), and an id (used to correlate the response). The server processes the request and returns a response object containing jsonrpc, id (matching the request), and either a result member on success or an error member containing a structured error code and message.

json
// Example Request
{
  "jsonrpc": "2.0",
  "method": "calculateSum",
  "params": [5, 10],
  "id": 1
}

// Example Success Response
{
  "jsonrpc": "2.0",
  "result": 15,
  "id": 1
}
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.