OpenHive

Message Formats

This document defines the message structures used by H.I.V.E agents.

Design Goals

  • Efficient overhead: Compact structure for scale
  • Fast parsing: Simple structure for high-performance processing
  • Easy implementation: Developers can implement in any language quickly
  • Human readable: JSON-based for debugging and development

Message Structure

All messages MUST follow this structure:

// Standard Message Format
{
  "from": "hive:agentid:abc123",
  "to": "hive:agentid:xyz789",
  "type": "task_request",
  "data": {
    /* Message-specific content */
  },
  "sig": "ed25519_signature"
}

Field Descriptions

FieldTypeDescriptionRequired
fromStringSender's agent IDYes
toStringRecipient's agent IDYes
typeStringMessage type (see types below)Yes
dataObjectMessage-specific payloadYes
sigStringEd25519 signature of the messageYes

Message Types

The Protocol defines the following essential message types:

Core Message Types

TypeDescription
task_requestRequest a task to be performed
task_responseAccept/reject a task request
task_updateProgress update during execution
task_resultFinal task results
task_errorError during task execution
capability_queryRequest agent capabilities
capability_responseAgent capability advertisement

Optional Message Types

TypeDescription
heartbeatAgent availability signal
agent_identityAgent Identification
contract_proposalFormal contract negotiation
auth_challengeAuthentication challenge

Design Goal: Most agents only need the 7 core message types. This covers the majority of use cases with minimal complexity.

Message Examples

Task Request

Request an agent to perform a capability:

{
  "from": "hive:agentid:client123",
  "to": "hive:agentid:translator456",
  "type": "task_request",
  "data": {
    "task_id": "task-789",
    "capability": "text-translation",
    "params": {
      "text": "Hello world",
      "target_lang": "es"
    },
    "deadline": "2025-07-18T15:00:00Z"
  },
  "sig": "ed25519_signature_here"
}

Task Response

Accept or reject a task request:

{
  "from": "hive:agentid:translator456",
  "to": "hive:agentid:client123",
  "type": "task_response",
  "data": {
    "task_id": "task-789",
    "status": "accepted",
    "estimated_completion": "2025-07-18T14:45:00Z"
  },
  "sig": "ed25519_signature_here"
}

Task Result

Deliver completed task results:

{
  "from": "hive:agentid:translator456",
  "to": "hive:agentid:client123",
  "type": "task_result",
  "data": {
    "task_id": "task-789",
    "status": "completed",
    "result": {
      "translated_text": "Hola mundo"
    }
  },
  "sig": "ed25519_signature_here"
}

Capability Advertisement

Advertise agent capabilities:

{
  "from": "hive:agentid:translator456",
  "to": "registry",
  "type": "capability_response",
  "data": {
    "capabilities": [
      {
        "id": "text-translation",
        "input": { "text": "string", "target_lang": "string" },
        "output": { "translated_text": "string" }
      }
    ],
    "endpoint": "https://translator456.example.com/api"
  },
  "sig": "ed25519_signature_here"
}

Error Response

Simple error handling:

{
  "from": "hive:agentid:translator456",
  "to": "hive:agentid:client123",
  "type": "task_error",
  "data": {
    "task_id": "task-789",
    "code": 404,
    "error": "capability_not_found",
    "message": "text-translation not available",
    "retry": true
  },
  "sig": "ed25519_signature_here"
}

Capability Query

Request capabilities from an agent or registry:

{
  "from": "hive:agentid:client123",
  "to": "hive:agentid:translator456",
  "type": "capability_query",
  "data": {
    "capabilities": ["text-translation", "image-processing"]
  },
  "sig": "ed25519_signature_here"
}

Message Validation

Required Validation Steps

  1. Structure Check: Ensure all required fields are present
  2. Signature Verification: Verify Ed25519 signature using sender's public key
  3. Agent ID Format: Validate agent ID format (hive:agentid:identifier)
  4. Data Validation: Check data payload against capability requirements

Signature Generation

// Example signature generation (pseudo-code)
const messageToSign = JSON.stringify({
  from: "hive:agentid:abc123",
  to: "hive:agentid:xyz789",
  type: "task_request",
  data: {
    /* payload */
  },
});

const signature = ed25519.sign(messageToSign, privateKey);

Error Handling

For invalid messages, respond with:

{
  "from": "hive:agentid:receiver",
  "to": "hive:agentid:sender",
  "type": "task_error",
  "data": {
    "code": 400,
    "error": "invalid_message_format",
    "message": "Missing required field: task_id",
    "retry": false
  },
  "sig": "signature"
}

Implementation Guidelines

For Massive Scale (Millions of Agents)

Performance Optimizations:

  • Use connection pooling for HTTP requests
  • Implement message batching for high-frequency communications
  • Cache agent public keys to avoid repeated lookups
  • Use compression for large data payloads

Security Best Practices:

  • Always verify signatures before processing messages
  • Implement rate limiting to prevent abuse
  • Use TLS for all communications
  • Rotate keys periodically

Error Handling:

  • Respond to invalid messages with clear error codes
  • Implement exponential backoff for retries
  • Log security violations for monitoring

Security Critical: Always verify message signatures before processing. Invalid signatures indicate potential security threats.

Performance Tip: For high-throughput scenarios, consider implementing message batching to reduce network overhead.