overview ~2 min
P2P Overview

P2P (Pipe-to-Pipe) enables TPipe agents to call each other through a registry system without exposing internal implementation details to LLMs.

P2P Overview

P2P (Pipe-to-Pipe) enables TPipe agents to call each other through a registry system without exposing internal implementation details to LLMs.

Core Components

ComponentFilePurpose
P2PInterfaceP2PInterface.ktContract for pipelines to participate in P2P calls
P2PDescriptorP2PDescriptor.ktAgent capability description
P2PRequirementsP2PRequirements.ktRuntime validation rules
P2PRequest/ResponseP2PRequest.kt, P2PResponse.ktRequest/response payloads
P2PRegistryP2PRegistry.ktAgent registry and dispatcher

Basic Usage

1. Implement P2PInterface

class MyPipeline : Pipeline(), P2PInterface {
    init {
        setP2pDescription(P2PDescriptor(
            agentName = "my-agent",
            agentDescription = "Does X, Y, Z",
            transport = P2PTransport(Transport.Tpipe, "my-agent"),
            requiresAuth = false,
            usesConverse = true,
            allowsAgentDuplication = false,
            allowsCustomContext = false,
            allowsCustomAgentJson = false,
            recordsInteractionContext = false,
            recordsPromptContent = false,
            allowsExternalContext = false,
            contextProtocol = ContextProtocol.none
        ))
        
        setP2pRequirements(P2PRequirements(
            maxTokens = 8192,
            allowExternalConnections = true
        ))
    }
    
    override suspend fun executeP2PRequest(request: P2PRequest): P2PResponse {
        // Handle the request
        val result = MultimodalContent().apply {
            addText("Processing completed successfully")
        }
        return P2PResponse(output = result)
    }
}

2. Register Agent

val agent = MyPipeline()
P2PRegistry.register(agent)

3. Call Agent

val request = AgentRequest(
    agentName = "my-agent",
    prompt = "Process this data",
    content = inputData
)

val response = P2PRegistry.sendP2pRequest(request)

Transport Support

P2P uses Transport.Tpipe, Transport.Http, and Transport.Stdio.

Transport.Python, Transport.Kotlin, Transport.JavaScript, Transport.Unknown, and Transport.Auto are not used for P2P.

When to Use P2P

  • Agent orchestration: Multiple agents need to call each other
  • Team boundaries: Different teams expose discoverable pipelines
  • Future remote hosting: Want stable contracts before implementing remote calls

For simple function calls, use PCP instead. For full pipeline-as-tool scenarios, use P2P.

Next Steps