Skip to content

Basic Communication Examples

Request-Response Pattern

javascript
// Agent A sends a request
const request = {
  version: "1.0",
  id: "req_123",
  type: "request",
  sender: { id: "agent_a" },
  recipient: { id: "agent_b" },
  payload: {
    action: "get_weather",
    parameters: {
      location: "New York"
    }
  }
};

// Agent B responds
const response = {
  version: "1.0",
  id: "res_456",
  type: "response",
  sender: { id: "agent_b" },
  recipient: { id: "agent_a" },
  payload: {
    temperature: 72,
    conditions: "sunny"
  }
};