code: func ServeAgent(agent Agent, c io.ReadWriter) error {
  	s := &server{agent}
  
  	var length [4]byte
  	for {
  		if _, err := io.ReadFull(c, length[:]); err != nil {
  			return err
  		}
  		l := binary.BigEndian.Uint32(length[:])
  		if l > maxAgentResponseBytes {
  			// We also cap requests.
  			return fmt.Errorf("agent: request too large: %d", l)
  		}
  
  		req := make([]byte, l)
  		if _, err := io.ReadFull(c, req); err != nil {
  			return err
  		}
  
  		repData := s.processRequestBytes(req)
  		if len(repData) > maxAgentResponseBytes {
  			return fmt.Errorf("agent: reply too large: %d bytes", len(repData))
  		}
  
  		binary.BigEndian.PutUint32(length[:], uint32(len(repData)))
  		if _, err := c.Write(length[:]); err != nil {
  			return err
  		}
  		if _, err := c.Write(repData); err != nil {
  			return err
  		}
  	}
  }
docs: // ServeAgent serves the agent protocol on the given connection. It
  // returns when an I/O error occurs.