|
| 1 | +# ANP-Agent Discovery Protocol Specification (Draft) |
| 2 | + |
| 3 | +## Abstract |
| 4 | + |
| 5 | +This specification defines the Agent Discovery Service Protocol (ADSP), a standardized protocol for discovering agents. Based on the JSON-LD format, it provides two discovery mechanisms: active discovery and passive discovery, aimed at enabling agents to be effectively discovered and accessed by other agents or search engines in the network. |
| 6 | + |
| 7 | +The core elements of the protocol include: |
| 8 | +1. Using JSON-LD as the foundational data format, supporting linked data and semantic web features |
| 9 | +2. Defining an active discovery mechanism, using .well-known URI paths as agent discovery entry points |
| 10 | +3. Providing a passive discovery mechanism, allowing agents to submit their descriptions to search services |
| 11 | +4. Supporting pagination and linking of agent descriptions, facilitating the management of large numbers of agent information |
| 12 | + |
| 13 | +This specification aims to enhance the discoverability of agents in the network, providing foundational support for building agent network ecosystems. |
| 14 | + |
| 15 | +## Introduction |
| 16 | + |
| 17 | +As the number of agents continues to increase, how to effectively discover and access these agents has become a key issue. The Agent Discovery Service Protocol (ADSP) aims to address this problem by providing a standardized way for agents to be discovered by other agents or search engines. |
| 18 | + |
| 19 | +This specification defines two agent discovery mechanisms: active discovery and passive discovery. Active discovery allows search engines or other agents to discover all public agents under a known domain; passive discovery allows agents to actively register their descriptions with search services. These two mechanisms complement each other, jointly enhancing the discoverability of agents. |
| 20 | + |
| 21 | +## Overview |
| 22 | + |
| 23 | +We use [JSON-LD](https://www.w3.org/TR/json-ld11/) (JavaScript Object Notation for Linked Data) as the format for agent discovery documents, consistent with the Agent Description Protocol. By using JSON-LD, we can achieve rich semantic expression and linking relationships while maintaining simplicity and ease of use. |
| 24 | + |
| 25 | +Agent description documents are detailed expressions of agent information, as referenced in the [ANP-Agent Description Protocol Specification](07-ANP-Agent-Description-Protocol-Specification.md). The agent discovery document serves as a collection page, containing URLs of all public agent description documents under a domain, facilitating indexing and access by search engines or other agents. |
| 26 | + |
| 27 | +## Protocol Details |
| 28 | + |
| 29 | +### Active Discovery |
| 30 | + |
| 31 | +Active discovery refers to search engines or agents only needing to know a domain to discover all public agent description documents under that domain. We adopt the Web standard `.well-known` URI path as the entry point for agent discovery. |
| 32 | + |
| 33 | +#### .well-known URI |
| 34 | + |
| 35 | +According to [RFC 8615](https://tools.ietf.org/html/rfc8615), `.well-known` URI provides a standardized way to discover services and resources. For agent discovery, we define the following path: |
| 36 | + |
| 37 | +``` |
| 38 | +https://{domain}/.well-known/agent-descriptions |
| 39 | +``` |
| 40 | + |
| 41 | +This path should return a JSON-LD document containing URLs of all public agent description documents under the domain. |
| 42 | + |
| 43 | +#### Discovery Document Format |
| 44 | + |
| 45 | +Active discovery documents adopt the JSON-LD format, using the `CollectionPage` type, containing the following core properties: |
| 46 | + |
| 47 | +- `@context`: Defines the JSON-LD context used in the document |
| 48 | +- `@type`: Document type, value is "CollectionPage" |
| 49 | +- `url`: URL of the current page |
| 50 | +- `items`: Array of agent description items |
| 51 | +- `next`: (Optional) URL of the next page, used for pagination scenarios |
| 52 | + |
| 53 | +Each agent description item contains: |
| 54 | +- `@type`: Type, value is "ad:AgentDescription" |
| 55 | +- `name`: Agent name |
| 56 | +- `@id`: URL of the agent description document (unique identifier of the resource) |
| 57 | + |
| 58 | +Example: |
| 59 | + |
| 60 | +```json |
| 61 | +{ |
| 62 | + "@context": { |
| 63 | + "@vocab": "https://schema.org/", |
| 64 | + "did": "https://w3id.org/did#", |
| 65 | + "ad": "https://agent-network-protocol.com/ad#" |
| 66 | + }, |
| 67 | + "@type": "CollectionPage", |
| 68 | + "url": "https://agent-network-protocol.com/agent-descriptions", |
| 69 | + "items": [ |
| 70 | + { |
| 71 | + "@type": "ad:AgentDescription", |
| 72 | + "name": "Smart Assistant", |
| 73 | + "@id": "https://agent-network-protocol.com/agents/smartassistant/ad.json" |
| 74 | + }, |
| 75 | + { |
| 76 | + "@type": "ad:AgentDescription", |
| 77 | + "name": "Customer Support Agent", |
| 78 | + "@id": "https://agent-network-protocol.com/agents/customersupport/ad.json" |
| 79 | + } |
| 80 | + ], |
| 81 | + "next": "https://agent-network-protocol.com/agent-descriptions/page2.json" |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +#### Pagination Mechanism |
| 86 | + |
| 87 | +When there are a large number of agents under a domain, a pagination mechanism should be adopted. Pagination is implemented through the `next` property, pointing to the URL of the next page. Clients should recursively retrieve all pages until there is no `next` property. |
| 88 | + |
| 89 | +### Passive Discovery |
| 90 | + |
| 91 | +Passive discovery refers to agents actively submitting their agent description URLs to other agents (typically search service agents), enabling them to index and crawl their information. |
| 92 | + |
| 93 | +#### Registration API |
| 94 | + |
| 95 | +Passive discovery typically requires using the registration API provided by search service agents. These APIs are defined by the search service agents themselves and should be clearly stated in their agent description documents. Agents can register their description URLs with search services by calling these APIs. |
| 96 | + |
| 97 | +#### Registration Process |
| 98 | + |
| 99 | +1. Agent obtains the description document of the search service agent |
| 100 | +2. Finds the registration API endpoint and parameter requirements from the description document |
| 101 | +3. Constructs a registration request, including its own agent description URL and other necessary information |
| 102 | +4. Sends the registration request to the search service |
| 103 | +5. Search service verifies the request and indexes the agent |
| 104 | + |
| 105 | +```mermaid |
| 106 | +sequenceDiagram |
| 107 | + participant Agent as Agent |
| 108 | + participant Search as Search Service Agent |
| 109 | + |
| 110 | + Agent->>Search: Get agent description document |
| 111 | + Search-->>Agent: Return description document (including registration API info) |
| 112 | + Note over Agent: Parse registration API from description document |
| 113 | + Agent->>Search: Send registration request (including own description URL) |
| 114 | + Note over Search: Verify request |
| 115 | + Search-->>Agent: Confirm registration |
| 116 | + Note over Search: Crawl agent description document and index |
| 117 | +``` |
| 118 | + |
| 119 | +### Security Considerations |
| 120 | + |
| 121 | +To ensure the security of agent discovery, the following measures are recommended: |
| 122 | + |
| 123 | +1. **Content Validation**: Search services should verify the validity and integrity of agent description documents |
| 124 | +2. **DID Authentication**: Use the did:wba method for identity authentication, ensuring the authenticity of agent identities |
| 125 | +3. **Rate Limiting**: Implement appropriate rate limiting measures to prevent malicious requests and DoS attacks |
| 126 | +4. **Permission Control**: Distinguish between public and private agents, only including public agents in discovery documents |
| 127 | + |
| 128 | +## Relationship with Other Protocols |
| 129 | + |
| 130 | +The Agent Discovery Protocol is closely related to the following protocols: |
| 131 | + |
| 132 | +1. **Agent Description Protocol**: The discovery protocol provides indexing and access mechanisms for description documents |
| 133 | +2. **DID:WBA Method**: Provides identity authentication and security guarantees |
| 134 | +3. **Meta-Protocol**: In agent communication, protocol negotiation can be based on discovery results |
| 135 | + |
| 136 | +## Copyright Notice |
| 137 | +Copyright (c) 2024 GaoWei Chang |
| 138 | +This document is released under the [MIT License](./LICENSE), you are free to use and modify it, but you must retain this copyright notice. |
0 commit comments